C# Programming > Miscellaneous

C# Request Google PageRank

 

Google PageRank

Google PageRank is a tricky subject. The PR value of a website is supposed to reflect the overall value of the site. However PR is rarely an accurate measure. Regardless, it is sometimes important to know the PageRank of a website.

Luckily the algorithm to request the PageRank value of a URL is public which makes it possible to implement in C#.NET.

Google Checksum

The trick to request the Google PageRank is to calculate the proper checksum of the given URL. Without the "google checksum" of the URL, you'll get a 403 Forbidden error.

As mentioned before, the checksum algorithm is public and easily implemented in C# (the source code has our implementation for C# developers). Not that this is not the algorithm for how PageRank is calculated. That's an entirely different algorithm, this is just to request the value from Google's datacenter.

Reading the Response

Once we calculated the Google checksum value of a URL, we can request the Pagerank value with a simple URL:

http://toolbarqueries.google.com/search?client=navclient-auto&ch=[checksum]&features=Rank&q=info:[url]

Here is a quick tip to avoid errors, the url must include "info:" at the beginning before the checksum value is calculated.

The URL is nothing fancy, and the server's response will be a string containing the Google PageRank value of the given URL. The simplest way to read it will be by using the .NET Framework's web classes, check out the downloading internet data in C# article for more detailed information.

If the URL has not had a PageRank value assigned to it yet, the server's response will be blank, which is easy enough to detect.

Using the Code

The algorithm to request Google PageRank in C# can be encapsulated into a static class, which I included below.

Back to C# Article List