利用php获取网站的谷歌pr值,网址请求谷歌api的URL地址为:
http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&q=info:www.maopiaopiao.com&ch=8a1467f12
点击上面这个网址你就可以免费看到本站的谷歌pr值了。
其中www.maopiaopiao.com为域名,ch参数为hash域名得到的值,ch参数计算的方法如下:
function app_hash_url($url){ $seed="Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE."; $result=0x01020345; for($i=0;$i<strlen($url);$i++){ $result^=ord($seed{$i%87})^ord($url{$i}); $result=(($result>>23)&0x1FF)|$result<<9; } return sprintf("8%x",$result); }
php完整获取谷歌pr值的实例如下:
/*php获取网站谷歌pr值完整示例*/ $url='www.maopiaopiao.com'; function app_hash_url($url){ $seed="Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE."; $result=0x01020345; for($i=0;$i<strlen($url);$i++){ $result^=ord($seed{$i%87})^ord($url{$i}); $result=(($result>>23)&0x1FF)|$result<<9; } return sprintf("8%x",$result); } $PR_CH=app_hash_url($url); $url='http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&q=info:'.$url.'&ch='.$PR_CH; echo file_get_contents($url);