[英]Jsoup wiki scraper how do I get table of contents box
I am having trouble scraping the table of contents on wiki. 我在刮除Wiki上的目录时遇到麻烦。 I am making a simple web scraper for a personal project and I can't figure out how to scrape this data. 我正在为个人项目制作一个简单的Web抓取工具,但我不知道如何抓取这些数据。
Here is my attempt at scraping the table of contents from any given wiki page 这是我尝试从任何给定的Wiki页面抓取目录的尝试
String contentOver = doc.select("#toclimit-3 > li").first().text();
HERE IS THE CODE FROM THE PAGE I want to scrape, how do I get just the word "Chronology"?: 这里是我要抓取的代码,请问如何仅获得“年代学”一词?
<ul>
<li class="toclevel-1 tocsection-1"><a href="#Chronology"><span class="tocnumber">1</span> <span class="toctext">Chronology</span></a></li>
You can just get it by the class name: 您可以通过类名获取它:
Element li = doc.select("#toclimit-3 > li").first();
String result = li.select(".toctext").first().text();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.