I am trying to get the number of articles that Google shows us:
This is a Google search of jeb bush barack obama
, and it shows the number that I need, which
Actually, you may be getting some optimized javascript code (for modern browsers) that need to be run to see actual results stats. Instead, change your user agent string (for a oldest browser UA string) and the url like in the code below:
http://try.jsoup.org/~iYErM3BgfjILVJZshDMkAd-XQCk
String url = "https://www.google.com/search?q=jeb+bush+barack+obama";
Document document = Jsoup //
.connect(url) //
.userAgent("Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)") //
.get();
Element divResultStats = document.select("div#resultStats").first();
if (divResultStats==null) {
throw new RuntimeException("Unable to find results stats.");
}
System.out.println(divResultStats.text());
About 10,500,000 results
Tested on Jsoup 1.8.3
More UA Strings: http://www.useragentstring.com/