Using Jsoup:
public static int getGoogleResultsCount(String query) throws IOException {
String url = "https://www.google.com/search?q=" + query;
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();
return Integer.parseInt(divResultStats.text().replaceAll("\\D", ""));
}