Yesterday I had the following results when searching in Google using the some keywords.
For example:
hate (About 397,000,000 results)
Now I want to write a program that search with google some words and store the result count.
How can I do this?
Yesterday I had the following results when searching in Google using the some keywords.
For example:
hate (About 397,000,000 results)
Now I want to write a program that search with google some words and store the result count.
How can I do this?
You can use the official Google API for this task. You will get a 100 queries for free per day. More queries cost.
First of all, download HtmlAgilityPack. Once you reference it in your project, you can do:
var doc = new HtmlWeb().Load("http://www.google.com/search?q=love");
var div = doc.DocumentNode.SelectSingleNode("//div[@id='resultStats']");
var text = div.InnerText;
Text will contain About 4,350,000,000 results (0.07 seconds)
All you have to do is parse the number now.
var matches = Regex.Matches(text, @"About ([0-9,]+) ");
var total = matches[0].Groups[1].Value;
You will have the number in total.
Note
If Google provides an API for this purpose, use it.
Also, make sure that scraping Google results isn't prohibited.
This is just an example of how to use an HTML Parser in C#.