<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function page_rank($page, $type = 'alexa'){ switch($type){ case 'alexa': $url = 'http://alexa.com/siteinfo/'; $handle = fopen($url.$page, 'r'); break; case 'google': $url = 'http://google.com/search?client=navclient-auto&ch=6-1484155081&features=Rank&q=info:'; $handle = fopen($url.'http://'.$page, 'r'); break; } $content = stream_get_contents($handle); fclose($handle); $content = preg_replace("~(\n|\t|\s\s+)~",'', $content); switch($type){ case 'alexa': if(preg_match('~\<div class=\"data (down|up)\"\>\<img.+?\>(.+?)\<\/div\>~im',$content,$matches)){ return $matches[2]; }else{ return FALSE; } break; case 'google': $rank = explode(':',$content); if($rank[2] != '') return $rank[2]; else return FALSE; break; default: return FALSE; break; } } // Alexa Page Rank: echo 'Alexa Rank: '.page_rank('4evertutorials.blogspot.in'); echo ' '; // Google Page Rank echo 'Google Rank: '.page_rank('4evertutorials.blogspot.in', 'google'); ?>
Monday, December 24, 2012
Website page rank php
12/24/2012
By:
4evertutorials
On: 12/24/2012
In: page rank by google, php website page rank, site page rank, url page rank
No comments
Get the page rank of any website supported by Alexa with this simple function.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment