Google Search API - Number of Results

Whenever you do a Google search, he spits out this little piece of information

"About 8,110,000 results (0.10 seconds)"

I use the number of results some terms return to rank them against each other, so if I could get this integer - 8,110,000 - through the API, it would be very useful. Some Google APIs are deprecated recently, so if you can point me to the correct version, which is not deprecated, it would be very helpful.

Any other workarounds would also be greatly appreciated. I saw one or two old posts on similar topics, but none of them were successfully resolved.

+7
google-search-api
source share
1 answer

Finished using Bing instead of Google and the following code:

string baseURL = "http://api.search.live.net/xml.aspx?Appid=<MyAppID>&query=%22" + name + "%22&sources=web"; WebClient c = new WebClient(); c.DownloadStringAsync(new Uri(baseURL)); c.DownloadStringCompleted += new DownloadStringCompletedEventHandler(findTotalResults); 

and this calls findTotalResults:

 void findTotalResults(object sender, DownloadStringCompletedEventArgs e) { lock (this) { string s = e.Result; XmlReader reader = XmlReader.Create(new MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes(s))); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name.Equals("web:Total")) { gResults = reader.ReadInnerXml(); } } } } } 
+4
source share

All Articles