Using C# to retrieve data from a Google search
Here's what I want the program to do:
- Read a text file (the text file contains random search criteria like "sunflower seeds", "chrome water faucets", etc) to retrieve a search phrase.
- Submit the search phrase to Google and retrieve the first four URLs.
- Retrieve the Google Page Rank of each of the returned URLs.
Being a neophyte C# programmer, I can handle #1 easily. Unfortunately, I've never dealt with using the Google APIs before. I do have a Google API key and I'm aware that there is a search limit using the API. At most, I'll probably use this on a dozen search phrases (or "keywords") per day. I can do this manually, but I know there has to be a way to do this with a C# program. I've read that this can be done using AJAX, but I don't know AJAX and I'd rather this just be an executable program on my PC rather than a web-based app. A push in the right direction from someone would be a big help. Also, I really don't want this to be a "screen-scraper", either. Isn't there a way that I can get the info (URLs and Page Rank) from Google without having to scrape a returned HTML search page?
I don't want anyone to write the code for me, just need to know if it's possible and a push towards finding the information on 开发者_如何学Gohow to accomplish it.
Thanks in advance everyone!
I don't want anyone to write the code for me, just need to know if it's possible and a push towards finding the information on how to accomplish it.
Look into the WebClient class
http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx
Try this:
googleSearch = @"http://" + @"www.google.com/#hl=en&q="+@query;
where query is the string of your search.
精彩评论