我是第一次接触Jsoup。
我可以使用select命令
Elements media = doc.select("[src]");如果你看到这个: en.wikipedia.org/wiki/States_and_territories_of_India。因为我想要所有的名字只在印度的国家。但是还有其他的表,当我执行doc.select(“areatitle”)时,我得到了所有的表信息。因此,如果在select中,我可以判断它是如何仅用于特定的表的,我就会进行检查。
如果是这样的话,我认为Jsoup可能不会解决这个问题,您能告诉我如何实现这一点吗?
发布于 2012-08-14 14:24:59
试试这样的东西
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());
}https://stackoverflow.com/questions/11946616
复制相似问题