[英]Jsoup select command operation
我是Jsoup的新手。
我可以使用选择命令
Elements media = doc.select("[src]");
如果您看到以下内容:en.wikipedia.org/wiki/States_and_territories_of_India。 因此,我只想拥有印度各州的所有名称。 但是,当我执行doc.select(“ area [title]”);时,还有其他表。 我正在获取所有桌子信息。 所以我在选择是否可以告诉我它如何仅用于特定表。
我认为Jsoup可能无法解决这个问题,请您告诉我如何实现
试试这个
Element indiaTable = doc.select("table").get(2); //India table is the third (index is 2) table on page
Elements myTds = indiaTable.select("td:eq(0)"); //The states are the first column
//or you can replace the two lines of code above with this
Elements myTds = doc.select("table.wikitable td:eq(0)");
for (Element td: myTds ) {
System.out.println(td.text());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.