我正在尝试从此网站上的表格中抓取一些数据:https://www.worldometers.info/coronavirus/
这是我尝试过的刮板的源代码
public static void main(String[] args) throws Exception {
String url = "https://www.worldometers.info/coronavirus/";
try{
Document doc = Jsoup.connect(url).get();
Element table = doc.getElementById("main_table_countries_today");
Elements rows = table.getElementsByTag("tr");
for(Element row : rows){
Elements tds = row.getElementsByTag("td");
for(int i = 0;i<tds.size();i++){
System.out.println(tds.get(i).text());
}
}
}catch (IOException e){
e.printStackTrace();
}
}
这是输出 中国 80,928 +34 3,245 +8 70,420 7,263 2,274 56 意大利 35,713 ....
我只想抓取一个特定国家/地区的数据,例如法国。 但是我不知道该怎么做。