tags:

views:

1244

answers:

3

C#: I want to write an application that will parse google for my website's ranking(position in the google search engine and NOT PageRank), where do I start?

  1. Does anyone know any examples doing so written in c#?
  2. What is the general direction you would start with? How should I parse google' web pages?
  3. Although I've searched for it, it's worth a shot: does anyone know of any google API that helps with this?

Thanks in advance

+4  A: 

Googles AJAX API will give you more easily processed search results. Without having to parse the acutal pages.

"For Flash developers, and those developers that have a need to access the AJAX Search API from other Non-Javascript environments, the API exposes a simple RESTful interface. In all cases, the method supported is GET and the response format is a JSON encoded result set with embedded status codes."

"Using the APIs from your Flash or Server Side framework couldn't be simpler. If you know how to make an http request, and how to process a JSON response, you are in business," says Mark Lucovsky.

http://code.google.com/apis/ajaxsearch/

Then as the results are returned in JSON you'll want to take a look at Json.NET (http://www.codeplex.com/Json) which will allow you to convert the JSON to more C# friendly XML.

Iain M Norman
A: 

You can write a simple text parser that grabs the url from the search page - I doubt that would be difficult. Or you can look into:

http://code.google.com/apis/gdata/docs/2.0/basics.html

nlaq
+1  A: 

The AJAX API mentioned above is probably the way to go, as it is what Google wants you to use within an application.

Screen-scraping is actually against Google's terms of service. Having said that, take a look at System.Net.WebClient:

var wc = new WebClient();
string html = wc.DownloadString("http://www.google.com/search?q=screen+scraping");
consultutah