问题描述
我正在尝试获取futbin上元素的内部html作为学习挑战,而该元素是目前最低的玩家。我可以正确识别元素,但内部html返回null。下面的代码以及我正在使用的futbin的HTML代码。
<div id="xBoxlowest" class="hide">52000</div>
final String playerPage = "https://www.futbin.com/21/player/583/alejandro-gomez";
try {
final Document document = Jsoup.connect(playerPage).get();
Element price = document.getElementById("xBoxlowest");
System.out.println("Price: " + price.html());
}
catch(Exception e){
e.printstacktrace();
}
}
价格:
对于这种网络抓取我还是很陌生的,所以关于我做错了什么的任何想法都值得赞赏。感谢您的答复
解决方法
您可以尝试这样
final String playerPage = "https://www.futbin.com/21/player/583/alejandro-gomez";
try {
final Document document = Jsoup.connect(playerPage).get();
var price = document.getElementById("xboxlowest").innerHTML;
var realprice=pInteger.parseInt(price);
System.out.println("Price: "+realprice);
}catch(Exception e){
e.printStackTrace();
}