Google PageRank Script

Welcome to the home of the Google PageRank script.

You’ll find all the information and code you need here:

Please feel free to leave your comments about PageRank below.

130 Responses to Google PageRank Script

← Older Comments Newer Comments →
  1. tyler dewitt says:

    The page rank script is giving me a 404 error they just did a google page rank update a few hours ago and ever since they did the update my script ain’t working I get a 404 back?

  2. hello Michael !

    i worked on your trick but unsucceeded.i also tried update command but fail. coz i dont know much abt mysql.

    what i want to do.

    i have table named : table
    i have rows in it
    ID : 0,1…
    Title: sites title
    Site: http://www.site.com, http://www.me.com….
    Pr: 0

    What i want to do is to automatically update pr of the tables.

    I want to fetch site address from Site row like > pagerank($row['Site']) and then update the Pr value from that.

    How can i do that?

    plz reply soon…

  3. Michael says:

    Hi Raja,
    i have tried to add you to msn a while ago but to no avail, yet ?

    For your Problem (you might have to change this example code… but something like this should work?)
    First get the Data from your mysql

    $sqlgetentries = mysql_query(“select ID, SITE, Pr from table);

    while you have results, check the pagerank and update it if the previous saved Pr has changed:

    while ($row = mysql_fetch_array($sqlgetentries)){
    $getpagerank = pagerank($row[' Site']);
    if ($getpagerank $row['Pr'){
    mysql_query("UPDATE table SET Pr='".$getpagerank"' WHERE id='".$row["id"].”‘”)
    }

  4. John says:

    Dude thank you a TON. Your script works perfectly, and even better than the original. I’m on some fairly new version of PHP5.

  5. Jon says:

    After a week of bashing my head against a wall, I’ve finally found a working script!

  6. John Loch says:

    I appreciate your efforts.

    I noticed (with my script) the checksum was mangled on my production box, but under WAMP with PHP 5.x it was fine. I implemented your checksum routine and it solved the problem.

    You saved me a lot of hassle and time.

    If I stop by again because you’ve created something I need, I’ll look once more for a donate button ;)

    Cheers :)

  7. Vivek Thomas says:

    Thank you very much for this. I had a script and it was not working fine on my server. Your scripts works perfectly.

    :)

  8. Monarchy says:

    Thanks for this script!

    For right working with url with “&” symbols you need to add $url = str_replace(“&”, “%26″, $url); to the function getpr()

    function getpr($url)
    {
    global $googlehost,$googleua;
    //$url = str_replace(“%26″, “&”, $url); если передается через параметр http://pravoslavie.name/pr/pagerank.php?url=http://monar.ru/index.php?article=sitemap%26page=5
    $ch = getch($url);
    $url = str_replace(“&”, “%26″, $url); // add this!!!
    $fp = fsockopen($googlehost, 80, $errno, $errstr, 30);

    Hello from Russia!
    The Tsar’s Russia will arisen!

  9. Brnden says:

    Took me forever to find this, but it works like a charm. Thanks.

  10. TechPro says:

    Thank you very much!

  11. NakedSnail says:

    Thanks,man.
    i use
    $googlehost=’toolbarqueries.l.google.com’;

    ok~~it`s work well;

  12. Really thanks for the script. Old one I was using from Google community was not working.

  13. John says:

    I’m trying to do a similar thing to Raja Amer Khan, running the function on a series of sites in a MySQL table. I’ve already got the queries set up OK (similar to what Michael suggested), but when I try to run the getpr function (because I just want the integer, and not the bar display), inside the loop generated by my select query, I get the following error message:

    Warning: fsockopen() [function.fsockopen]: unable to connect to :80

    If I run the script by itself with a URL in the querystring, it works OK.

    Any idea what I’d need to do to get it working with my query?

    (Which looks like this if that helps:

    $result = mysql_query(“SELECT `site_url`, `site_id` FROM `sites` ORDER BY `site_id`”);

    while ($value = mysql_fetch_array($result)) {
    $rank = getpr($value['site_url']);
    $id = $value['site_id'];
    $result2 = mysql_query(“UPDATE `sites` SET `site_google` = ” .$rank. ” WHERE `site_id` = ” .$id);
    }

  14. Michael says:

    I can just imagine, that somehow the script did not get the $googlehost, since the errormessage just tells about Port 80 with nothing before it ?
    Not sure but I`d check where and how the $googlehost is set and if the Funkction does actually knows it …. ?

  15. Pingback: The Ultimate Web Design Gallery Resource — Tyssen Design

  16. forum says:

    very nice thanks !

  17. You’re freakin genius!

    Thank you and keep the good work!

  18. Angra-Mainyu says:

    Hello,
    I try your script on my server who is hosted by OVH, but it don”t work.
    On a local server, i get the good page rank.
    You can see the result at
    http://www.webmestre-annuaire.com/pagerank/mypagerank.php
    Thanks for your answer.

  19. Kicko says:

    Thank you!!! It’s working on my servers …

  20. Pingback: Pygmalion » Blog Archive » Google PageRank in PHP

  21. Tum says:

    Thank a lot!!!

  22. Pingback: Twitter Tweets about PageRank as of July 23, 2008 : The Lessnau Lounge

  23. Pingback: Google pagerank checker php script free download - DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums

  24. Paolo says:

    it seems a good script, I’m looking for one that allow webmasters to grab a html code and paste on their webpages to show pagerank
    it would be a fantastic source of (almost) free links

    check stats21.com seo stats tool to make u an idea of what I’m talking about

    is this script useful for me?

  25. Joe says:

    Not too bad. I hacked up a utility that will get the PR for thousands of domains in one quick easy pass…

  26. talle says:

    This scrip support SOCKs proxies?

    Regards.

  27. hrumos says:

    Man, thanks !
    Its what i searched for.

    You are great one.

  28. Migs de Villa says:

    awesome!

    was a few days looking for a real one.

    keep it up!

  29. Scott says:

    Any ideas how to get around this problem?

    We’re sorry…

    … but your query looks similar to automated requests from a computer virus or spyware application. To protect our users, we can’t process your request right now.

    We’ll restore your access as quickly as possible, so try again soon. In the meantime, if you suspect that your computer or network has been infected, you might want to run a virus checker or spyware remover to make sure that your systems are free of viruses and other spurious software.

    We apologize for the inconvenience, and hope we’ll see you again on Google.

  30. Michael says:

    @Scott:
    You can generate this type of error by making searches as fast as possible (5-10/sec). At one point google will think you’re a bot, hence the “your query looks similar to automated requests from a computer virus or spyware application”.

    So you might want to reduce the speed and/or the amount of request to google.

    I have now made it so, that i request a Pagerank for a site when i add it, put the PR-Value into a mysql-Database and also save the Date of the request.
    While displaying the pagerank i check the date and if it is x days old (lets say 30 or maybe 90 days) i let it update and save the (maybe) new pagerank and new date.
    Otherwise i just display the pagerank it has already got.

    For me this has 4 good sides:
    1: I wont mass-request google
    2: the display of many pageranks per Site is much faster
    3: more accurate when googles server isnt responding
    4: I can check, what pageranks i have grouped by its value (e.g. 3523 x PR 3)

    Updates will mostly done by visitors of my sites, so it keeps itself updated for frequently visited entries.
    The bad side might be, that when google does updates while the date isnt too old, it will show the old, outdated pagerank…. and of course a higher amount of Database-request (might wanna add some caching some day … but its running fine right now, so why not beeing lazy? *grin*)

  31. Michael says:

    Addtition:

    I also check how many entries i have and check against how many pageranks i have saved.
    So i can be pretty sure, if all sites are checked.

    Since i actually have 13089 (and counting ^^) entries i cant really check and keep them updated manually.

  32. Adam says:

    Thanks HM2k, I found a few PHP pagerank scripts on the web but yours seems the best.

  33. is there any way to tell whether PR is 0 or there was some error? I’m writing results to the DB and would really like to know…

  34. Pance says:

    Thanx a lot pal, it works like a charm :)

  35. Michael says:

    @ Mateusz Mucha:

    Check out Function getpr and have a look a:
    if($pos === false){//you could add something maybe to $pr here ^^ }

  36. mushtaq says:

    thanks Pal
    Keep up the good work.
    :)

  37. yamazon says:

    hello.
    I’m Japanese.
    I had been looking for this script for a long term.
    It is very glad to me.
    thanks!!!

    the script moved when changing as follows.

    ##
    hammer said,
    You need to make a change at the bottom of the page in the last 2 lines
    take away the // symbols in front of the line that has them at the beginning, save it, then retest it
    ##

    Thank you for everybody.

  38. ashish sharma says:

    hi ,
    I use this script in my website and upload it on my server, it work well when i used it on the local server , but when i uplaod it to the main server it show the blank page …………….
    plz help me out from this problem , suggest me what to do………….

  39. SEO chambee says:

    hi.

    it is very nice script for me.

    thank you very much.

  40. Top 10 host says:

    awesome!

    was a few days looking for a real one.

    keep it up!

  41. hm2k says:

    To showcase my script I created this:

    http://www.pagerankviewer.com/

    Hope you find this useful.

  42. Genta says:

    Great!!! Works!!!
    Actually I tested it in local. As soon as possible I will put it on my online web server. I hope that the script will work online too. A lot of web servers are incompatible with this kind of scripts. I come back to write if works when I finish.
    Sorry for my poor English…

  43. Arun M says:

    Great Work, Thank you very much for sharing.

  44. Dave says:

    Am I missing something? Where do I download the code for this?

  45. Dave says:

    I’ve just tried the script and it gives me a 403 Forbidden error. Isn’t this script supposed to “fix” the 403 error?

  46. hm2k says:

    @Dave

    Download the latest here: http://hm2k.googlecode.com/svn/trunk/code/php/scripts/pagerank.php

    See it in action here: http://www.pagerankviewer.com/ (It does work)

    If it’s not working, it may be a problem with how your server calculates the checksum, you may need to upgrade PHP.

  47. Dave says:

    Thanks…

    I’m using PHP version 4.4.9

    Can you tell me if this should be sufficient or what version I would need?

    Thanks

  48. hm2k says:

    @dave

    PHP5 -> http://www.gophp5.org/

    PHP4 was first released 10 years ago, it’s time to move on.

  49. Dave says:

    Cheers – have just switched server to 5 (my provider sets 4 as default for some reason). Script now working perfectly.

    Many thanks for the script and your help.

← Older Comments Newer Comments →

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>