In usual, when you want to check the Google Pagerank of entire website (checking the PR of all the internal pages), you must have to visit each page individually, many online multiple Pagerank checkers can only offer you an ability to check PR of multiple domain a time, so in this tutorial, I will show you how to build an Entire Website Pagerank Checker script with PHP.
The process we need?
As our main target, the script we build must do two functions:
- The first: Get all page links of the specific website.
- The second: Checking the Google PageRank of each link then output all of them.
Step 1 Get all page links of the website
In this step, I’ve asked myself that “How can I get all internal page links of a website?”, then some ideas appeared in my mind: building an automatic bot to craw through the website (too hard to build and maybe you will get banned from the bad bot blocker if your bot visit the website many times a day), follow any internal link that appeared on the front of the website with depth level is 2 or 3 (I think it couldn’t go through all post), using google index to get the post link, using the RSS output (the same reason above)… And the final tool I want to use is a Website Sitemap (An XML sitemap), why?
- Almost websites, especially WordPress sites are using XML Sitemap (with the help of Google XML Sitemaps plugin – 3,833,876 downloads up to now)
- The sitemap usually shows all the page/post links of the website and we can get all of them for the main purpose.
Take the first look of the XML sitemap, for example: http://www.intenseblog.com/sitemap.xml… and the source of this:

As you see, the URL of each page was wrapped by <loc>...</loc> tags, all things we should do are get that values. So the first PHP code is:
<?php
function content($parser, $data){ // This function will get all the value between <loc>, <lastmod>, <changefreq>, <priority> of the sitemap
global $arrlink; // We MUST set arrlink to a global array
$first = substr($data, 0, 4); // we get first 4 character of each value...
if ($first == "http") { // ... and then checking if the value is an URL...
array_push($arrlink, $data); // ... then pass the value to arrlink
}
}
function geturlcontent($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$data = geturlcontent($url);
$arrlink = array();
$xml_parser = xml_parser_create();
xml_set_character_data_handler($xml_parser, "content"); //Character data handler is called for every piece of a text in the XML document
if(!(xml_parse($xml_parser, $data))){ // If there is an arror.. output it
die("Error on line " . xml_get_current_line_number($xml_parser));
}
xml_parser_free($xml_parser); // If you don't call xml_parser_free() before your script ends, some sort of ugliness occurs with the webserver
?>
In the code above, we only use xml_set_character_data_handler NOT xml_set_element_handler because we only need the value between <loc>...</loc> tags, there’re nothing in <loc> tag for us.
For this Php script can work, we must get the content of the XML sitemap, I know many ways for us to do:
1/ Using fread: http://php.net/manual/en/function.fread.php
Fread is great if the sitemap has a small size, if greater, the script will only process small piece of the sitemap.xml (Fread can read maximun as 8192 bytes)
2/ Using file_get_contents: you should use this when your web server doesn’t support cURL, the code will be:
$data = file_get_contents($file);
3/ Using include and read_file…
4/ Using cURL (I love this way) because it’s safer and faster to work, so I add this function to get the content of sitemap.xml:
function geturlcontent($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
We create an array named as arrlink to store all the web page links we’ve got, at first, arrlink is empty then we create content function to pass the URL value to this array, by this array we can use it for any other purposes with php :)
And we’re almost finish the first step, lets move to the next step.
Step 2 Checking the Google PageRank of each link
First, we need a Php script to check the pagerank of a given URL, I found one free script which works very well, you can download it at: http://www.diagnosticoweb.com/wdscript/free.php, the script is free for using and can check the domain Alexa rank and popularity, Google backLink, DMOZ Listed…. but we only need Google Page Rank checking tool.
You must download and upload the script as the same folder of our script. then we make an input form for you to put in the URL of a Sitemap.xml:
<form action="" method="post" name="checkpr" id="checkpr">
<p>Put The XML Sitemap Link Here:</p> <input type="text" name="sitemap" value="<?php if (isset($_SESSION['sitemap'])) {echo $_SESSION['sitemap'];} ?>" size=80 />
<input type="submit" value="Process" />
</form>
… and a code to handle the form:
session_start(); // We need it because I want after the form button was clicked, the sitemap URL still appeared in the input field
$success = '';
if (isset($_POST['sitemap']) && $_POST['sitemap'] !== '')
{
$success = 'ok';
$url = $_POST['sitemap'];
$_SESSION['sitemap'] = $_POST['sitemap'];
}
Ok, we will process the sitemap.xml that we were received:
if ($success == 'ok') {
echo '<ul>';
ob_end_flush();
for ($i=0;$i<count($arrlink); $i++) {
$pr = getPageRank($arrlink[$i]);
if ($i % 2) {
echo '<li class="two"><a href="'.$arrlink[$i].'">'.$arrlink[$i].'</a>PageRank <font color="red">'.$pr.'</font><div class="clear"></div></li>'; flush(); sleep(1);
}
else {
echo '<li class="one"><a href="'.$arrlink[$i].'">'.$arrlink[$i].'</a>PageRank <font color="red">'.$pr.'</font><div class="clear"></div></li>'; flush(); sleep(1);
}
}
echo '</ul>';
unset ($success); // reset the success variable
session_unset(); // reset the current Session
}
In the code above, I used ob_end_flush(); and flush(); sleep(1); to make the script output the content when running, if not, the script only output the content after the For loop finished.
The Final Script
After adding CSS markup, here is the final script code to get the Google Pagerank of entire website:

<?php
set_time_limit(0);
include('pagerank.php');
session_start();
$success = '';
function content($parser, $data){
global $arrlink;
$first = substr($data, 0, 4);
if ($first == "http") {
array_push($arrlink, $data);
}
}
function geturlcontent($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
if (isset($_POST['sitemap']) && $_POST['sitemap'] !== '')
{
$success = 'ok';
$url = $_POST['sitemap'];
$_SESSION['sitemap'] = $_POST['sitemap'];
$data = geturlcontent($url);
// $data = file_get_contents($file);
$arrlink = array();
$xml_parser = xml_parser_create();
xml_set_character_data_handler($xml_parser, "content");
if(!(xml_parse($xml_parser, $data))){
die("Error on line " . xml_get_current_line_number($xml_parser));
}
xml_parser_free($xml_parser);
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Multiple PR Checker</title>
<style type='text/css'>
body {min-width:950px;background:#eee}
.container {width:940px;margin:10px auto;background:#fff;padding:10px;border:1px solid #ddd;text-align:center}
#checkpr {padding:5px;background:#afc156;color:#fff;font-size:20px;text-align:center}
input {padding:5px}
ul {list-style:none;width:100%;padding:0;}
li {padding:5px;margin:2px 0;border:1px solid #ddd;text-align:right;font-size:16px;}
.one {background:#d7eaff}
.two {background:#d9e4a3}
li a {color:#18479B;text-decoration:none;float:left}
.clear {clear:both}
</style>
</head>
<body>
<div class="container">
<form action="" method="post" name="checkpr" id="checkpr">
<p>Put The XML Sitemap Link Here:</p> <input type="text" name="sitemap" value="<?php if (isset($_SESSION['sitemap'])) {echo $_SESSION['sitemap'];} ?>" size=80 />
<input type="submit" value="Process" />
</form>
<?php
if ($success == 'ok') {
echo '<ul>';
ob_end_flush();
for ($i=0;$i<count($arrlink); $i++) {
$pr = getPageRank($arrlink[$i]);
if ($i % 2) {
echo '<li class="two"><a href="'.$arrlink[$i].'">'.$arrlink[$i].'</a>PageRank <font color="red">'.$pr.'</font><div class="clear"></div></li>'; flush(); sleep(1);
}
else {
echo '<li class="one"><a href="'.$arrlink[$i].'">'.$arrlink[$i].'</a>PageRank <font color="red">'.$pr.'</font><div class="clear"></div></li>'; flush(); sleep(1);
}
}
echo '</ul>';
unset ($success);
session_unset();
}
?>
</div>
</body>
</html>
Also, you can download it all at: http://www.intenseblog.com/file/check-pagerank.zip :)
Have you ever been dissatisfied with your income? Don't waste your time any more, take the lessons I've learned in 3 years and start making your money online the right way now!
(Currently being sold on Amazon - Limited offer only for IntenseBlog's readers)


















Thanks for this work friend. Will try this out.
Nice work.
Techozens last post: 6 reasons why U should switch to dofollow blog
Wow thanks for the download link . There are no sites untill now which displays the page ranks ofall blog posts :D . Looks brillinat idea
Thanks , will try it out
BLOG404 last post: Blog Contest – Cash Prizes to be won !
Getting the PR of all pages is very helpful in order for you to check what particular posts are loved by your audience. You could actually do strategies for it to take advantage of the result.
Cole Stan last post: Birthday Gifts for Dad- You Can’t Go Wrong with These 3 Great Birthday Gifts for Dads
Thank for your tip. It is relly wonderful.
thanks for the heads up i must say nice been here two days ago now you have a new theme site looking great
lawmacs last post: 3 Ingredients To Success
Thanks, there’re many things to do when set up a new theme :), nice to meet you.
Useful to have your own private checker ;)
Ashfame last post: WordPress Multisite non-WWW forwards to Signup Page Problem Fix
Wow, this is exactly what I was looking to do as my next little project. I’m going to copypasta your code and play around it with in my admin section for my little server farm.
Steve last post: Perspective Broker Authentication for Stackless Python
thanks, nice info.. i think i must learn more about this..!
kibagus last post: Mengenal Google SketchUp software desain grafis 2D dan 3D
Amazing ……….. I love you :D
Hi Jennifer, great post.
I don’t know php but i would like to try the script, could you put a download link to the files?
Thank you
Cristian last post: Piranha 3D 2010
Before I create a download file, you could copy all the code of the Final script section, good luck with it.
Is there a way to transform this idea into a WP plugin? Many people are looking for such a tool, including me :)
Cole Stan last post: Anniversary Gifts For Men – Rock His World With These Romantic Gifts
Pretty awesome and exactly what I was looking for, one thing when I just copied and used your script it needed a pagerank.php for the include, I realized that the zip from the previous link you say was needed has no php files with this name so the domaintool.php from the wdscript download needs to be renamed to pagerank.php and uploaded to the same directory you put your script. This took a few minutes to figure out but works great!
Justin Germino last post: Are You an Askable Blogger
wow! this is a very cool idea to check PR
tospider last post: Facebook will make About 15 Acquisitions in the Next Year
Great. I already searched something like this but I didn’t find. Thanks for the tutorial.
Blogueigoo last post: Software de Gestão Financeira – GNUCash
mantap pak artikelnya, ane copas dulu yah wat dipelajarin
Nice article. All aspects very good explained, I’ll try to follow them. Thank’s for sharing
Seo Dizain last post: Из попы – в топы!
This is going to come in so handy. I have so many sites I deal with this could really help me identify some good pages. THANKS!
Though I’ve been using the OpenSiteExplorer, I may have to do this…
amazing article.. can u share in PDF?
Mila Sari last post: Torch BlackBerry 9800 – RIMs New Design
I tried this out and it works like a charm. It was even able to process my 1600+ URLs in my sitemap like a charm. Great tool. Now I can start tracking my important URLs and work the PR on them. Thanks.
It took me a little while to figure this out, because I also missed the fact that you have to download the ‘domaintool.php’ and rename it ‘pagerank.php’.
So in the end I named my new page ‘prchecker.php’ using the script provided above and then uploaded both files ‘prchecker.php’ and ‘pagerank.php’. to my server in the same directory and it worked great after that.
Great to see all my posts with PR logged against them. Now I really know whats going down well and what isn’t. Great script.
you are so genius …. A + for you
You are right, Jenni – this is a bit above my head, but thanks of the link; I am sure some of my readers will find it interesting.
Ana
Ana @ MarketMeSuite last post: How to Build an Email List 101
Nice tutorial and easy to practice. Thanks!!
jasa desain rumah last post: Desain Renovasi Rumah Klasik Kontemporer di Bintara
Hi,
I’m affraid the link to the other script is broken. :( Can you help?
Thanks,
Robin
Hi Robin, you can download all script via this link: http://www.intenseblog.com/file/check-pagerank.zip
HI Jenni,
Thanks a bunch for the file, it worked flawlessly. Also, I am very much impressed with the instant answer I got for you!
Thanks, I’m charmed.
Robin
Robintel last post: Poze din Valea Dinozaurilor
Great! If you’ve any problem with this tutorial please don’t hesitate let’s me know.
Jenni
Thanks Jenny for great tip but is there any way to check pr for blogger blogs thanks :)
Detailed explanation of the code and steps. Even with little or no PHP knowledge one can do this!. Thanks for the excellent SEO tip
I just uploaded this in my server and it seems to work right although i have some problems getting it to see all the links in the sitemap. Thanks alot for sharing. Great script :)
thanks for code :)
Nice post. Thanks for sharing your thoughts. I’m looking forward to reading your post updates.
Thanks for this great tutorial i wonder if you could unveil such for blogger platform if at all there is any. I will try it on my new wordpress blog if i can grab it successfuly
Hi Jenni,
I tried the code but unfortunately pagerank pagerank values instead of just writing it out does not appear. How can I fix this?
Seems like the wonderful tool you created has stopped working. I noticed a few Google PR checkers also stopped working, so there may have been an update to how Google present PR that has caused this glitch.
I would love to get it working again so thought I would mention it to you to see if you were aware of the problem.
Thanks
Brian
This is great! You explained it real well. I will try this. Thanks!
THis is going to be huge… thanks for the detail…. >>>>>>>>> used ob_end_flush(); and flush(); sleep(1); to make the script output the content when running, <<<<<<<<<<<<<<<< KEY
Jacksonville SEO Expert last post: Google reorganization? What does it mean to your business?
is there any website who are catering this kind of all website pages checking for page rank? please help..
I don’t have knowledge about PHP, but reading this post was interesting and knowing the page rank of each page of the website will only let you know that which post is more popular.
-Preethi
http://www.brainwavelive.com/services/python-application-development.html
Very nice script. It help me a lot
In August Google checked the way they do lookups and expired their old methods.
You need to update any references that say:
http://toolbarqueries.google.com/search
and
http://www.google.com/search
to
http://toolbarqueries.google.com/tbr
Alternatively, you can find the latest pagerank scripts here:
https://github.com/phurix/pagerank/
Thank you so much, Stanley.
An awesome article with a clean explanation :) thanks for sharing dear.
It does not seem to be working for me. I have the script uploaded on my webserver and it does not pull the pagerank or any other rank information.
just visit
http://revolutioners.com/pagerankchecker/
and insert your sitemap or use mine which is
http://revolutioners.com/sitemaps/revolutioners-com.xml
Excellent tips and script. Can you tell me is there any source to get this working script for download. I need to download this script to deploy in my new site.
Thank you so much, this really looks wonderful,… but it turns out that all my pages have no PR, while the Google toolbar show values from 0 to 4. Where am I doing wrong?
I downloaded the two php files into a separate folder called PR. Then I access the file pr/index.php, I write the path to the ror.xml, and see all the files listed, but no PR :((
Can you help me?
Only after posting I saw Stanley post, explaining why the script it is not working.
I updated the pagerank.php file, replacing any references that say:
http://toolbarqueries.google.com/search or http://www.google.com/search
to
http://toolbarqueries.google.com/tbr
And now it works. Brilliant, this is really usefull. Thankyou!!!!!
http://jargoned.com/internalpagerankchecker/
This script still works and it works beautifully too. On my other website it located over 60 pages having pagerank. I was looking exactly for a service like this, so thank you, I have it uploaded myself, so the service will only die when my website die’s! :P
odd, yours doesn’t work for me at all.
Brandon last post: The Life of Blogging: Week 2
Google has changed the way to show pagerank, lets me see…
I would like to check my blog’s pagerank which is not only front page but also all posts in it. still searching till now.
Hello Jenni, I was wondering what your restrictions are for use of your code. I want to display a working form of such on my site based off of your tutorial, and would be more than happy to link back here.
Just want to make sure you’re ok with it though!
It’s fine Brandon :)
I’ve just updated the new version of the script, thank you Stanley for your idea :)
http://www.intenseblog.com/tutorials/check-pagerank-of-all-pages-within-site.html#comment-12123
Perfect, thanks!
Brandon last post: The Life of Blogging: Week 2
Is it all in the one download folder now?
Brandon last post: The Life of Blogging: Week 2
Yes, you’re!
Looks like a great script, I downloaded it and tried the first xml sitemap but I am not sure if the script works i.e. any idea how long it would take to process an xml file of about 889 Kb? I suspect it is rather big.
And isn’t it possible to let it generate output while running? I thought I read this somewhere.
Or is it just not working?
(p.s. I’ve put index.php and pagerank.php in a seperate directory)
Roughly 5800 links in it.
This morning I tried the pageranker script again but I suspect it causes a time out (without an error message) with so much links, is there a way to regulate the script somehow so it would perform in chunks?
hello!,I really like your writing so a lot! percentage we keep up a correspondence extra about your article on AOL? I require an expert in this area to unravel my problem. May be that is you! Having a look ahead to see you.
I tried this out and it works like a charm. It was even able to process my 1000 URLs in my sitemap like a charm.
Jenni, Thanks for providing this for free. I have downloaded the script and I am going to test it out. Will I have to modify the PR checks or did you update the script ?
Thanks
David
I’ve already updated the script, just start using it, David.
Thank you for the script helped me a lot :)
Raquel Johnson last post: Top 4 Reasons for Buying External HDD [www.FORTRICKS.in]
Thanks Jenny for great tip but is there any way to check pr for blogger blogs thanks :)
Does blogger blog has an xml sitemap?