[英]Jsoup select command operation
I am new to Jsoup. 我是Jsoup的新手。
I am able to use select command 我可以使用选择命令
Elements media = doc.select("[src]");
if you see this : en.wikipedia.org/wiki/States_and_territories_of_India . 如果您看到以下内容:en.wikipedia.org/wiki/States_and_territories_of_India。 In that I want to have all the Names in States of India only.
因此,我只想拥有印度各州的所有名称。 But there are other tables also , when I do doc.select("area[title]");
但是,当我执行doc.select(“ area [title]”);时,还有其他表。 I am getting all the table information .
我正在获取所有桌子信息。 so I am looking if in select I can tell how it is used to only for a particular table.
所以我在选择是否可以告诉我它如何仅用于特定表。
I think Jsoup might not address this if that is the case,can you please tell me how to achieve this 我认为Jsoup可能无法解决这个问题,请您告诉我如何实现
Try something like this 试试这个
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.