使用Jsoup计算谷歌搜索结果

时间:2015-10-12 15:42:13

标签: java jsoup

所以我试图通过java 没有Api 来获得Google计数结果。我试着用Jsoup库做到这一点。问题是他找不到div我正在寻找名为resultStats。

我的代码:

org.jsoup.nodes.Document doc  = Jsoup.connect("https://www.google.co.il/webhp?sourceid=chrome-instant&rlz=1C1LENP_enIL60,jvagazvgsaswgfwf7IL607&ion=1&espv=2&ie=UTF-8#q="+query).get();
Elements info = doc.select("div#resultStats");

this is the div I'm looking for, inspect element on Google search...

1 个答案:

答案 0 :(得分:0)

你可能正在寻找类似的东西:

Document doc = Jsoup.connect("https://www.google.co.il/search?q=test").get();
String info = doc.select("div#resultStats").text();
System.out.println(info);

问题在于您的 Google查询网址,而不是jsoup代码本身。