如何使用jsoup从网站获取所选数据(屏幕 - 总拍摄数量)?
更新了代码(仍未返回预期值):
try {
final Document document = Jsoup.connect("https://www.betfair.com/exchange/plus/#/football/market/1.127737590").get();
for (Element statItem : document.select("div#stat-item")) {
for (Element child : statItem.children()) {
System.out.println(child.attr("class") + " = " + child.text());
}
}
} catch (IOException e) {
e.printStackTrace();
}
答案 0 :(得分:0)
如果您只需要标题,请尝试:
try {
final Document document = Jsoup.connect("www...").get();
for (Element row : document.select("div#si-title")) {
System.out.println(row.text());
}
} catch (IOException e) {
e.printStackTrace();
}
如果您需要stat-item
的更多值,请尝试以下操作:
try {
final Document document = Jsoup.connect("www...").get();
for (Element statItem : document.select("div#stat-item")) {
for (Element child : statItem.children()) {
System.out.println(child.attr("class") +" = " +child.text());
}
}
} catch (IOException e) {
e.printStackTrace();
}