Google Pagerank in PHP

Due to recent changes made by Google in its Page Rank processing the following library doesn’t work. However you can try to use the following api made available by

Mark Woodman has created a nifty class which lets you query Google pagerank info in PHP 5 and above. The complete classes are available here.

The minimum classes required are ‘cacher.class.php‘ and ‘google_pagerank.class.php‘.

Sample code is shown below.


$rankObject = new GooglePageRank("");

$pageRank = $rankObject->pagerank;

echo $pageRank;

The class also supports result caching on the local machine, so if a second query arrives within the cache time limit the result saved in the local file is returned rather then going out and querying Google.

The ‘GooglePageRank’ class accepts cache time as a second parameter. So if you want to cache the result for 6 hours you set the second parameter for 21600 seconds (6 * 60 * 60):

$rankObject = new GooglePageRank("", 21600);

The default is set to 24 hours, which is more then adequate for most purposes.

28 thoughts to “Google Pagerank in PHP”

  1. It works. For e.g it gives a page rank of ‘4’ for ‘’.

  2. This topic is a little old, but files are still there so I’d like to suggest something:
    In line 50 of google_pagerank.class.php file you used ‘urlencode’ function. It works until there is ‘&’ in link string, otherwise ‘&’ is treated as another Google’s parameter. Changing ‘urlencode’ to ‘rawurlencode’ solves the problem.
    Nice work btw!
    P.S. Another little suggestion: try adding cURL (if unable to file_get_contents) and various Google Server (and get it random when checking – that way you won’t have to do ‘usleep’ being afraid of ban from Google).

  3. Good morning,
    we are announcing you Eman Engine Stats, a useful FREE script to show important informations of a web site ranking, backlinks and indexing.
    It is free. We attach you a presentation below.
    A demo version is downloadable from this link and is also attached :

    The web site of the script is
    The full version is downloadable only from our web site with the request of a recip link.

    You can show it on your web page
    For contact :
    Thanks and good work to everybody,
    Emanuel Celano

    Eman Engine Stats is an important php and flash script to check your ranking, backlinks and indexed pages directly from your web site (NO DEPENDENCIES from other web sites), every time you desire or automatically with an include file that run like a cronjob.
    Do you want to check your Google Ranking, Alexa Ranking ? Do you want to know the number of backlinks and the number of indexed pages from Google, Yahoo, Msn, Altavista, Alltheweb and to monitor the total value at a glance ? Do you want to look at the differences between two checking, to monitor on real time your search engine visibility ? Useful for web companion of submission and optimization on search engines. Do you want a tool that fit to your graphical page ? You can do it with the possibility to change the flash file background colour by your own.
    Eman Engine Stats is for you ! And it is free ! There are two versions of the script. The lite version that is free and the full version, free for now.
    To use these tools we only request to provide a link back to our site :
    The script show also the Google last visit date on your web site and is protected with a login form included into the flash file. It is easy to use thanks to detailed informations of installation step by step.

  4. Nice script could be used for archiving page rank for your sites on a cron job. say, running it once a day. Then, you can see when google is doing another page rank run.

    Which is handy information for you and if you have any customers, for them also!

Leave a Reply

Your email address will not be published.