首页 > 开发 > PHP > 正文

php获取google pr 值的代码

2024-05-04 21:58:56
字体:
来源:转载
供稿:网友

功能:对URL进行编码

参数说明:$web_url 网站URL,不包含"http://",例如Vevb.com

php获取google pr 值的代码如下:

  1. function HashURL($url){ 
  2. $SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer."
  3. $Result = 0x01020345; 
  4. for ($i=0; $i<strlen($url); $i++)  
  5. $Result ^= ord($SEED{$i%87}) ^ ord($url{$i}); 
  6. $Result = (($Result >> 23) & 0x1FF) | $Result << 9; 
  7. }//开源代码Vevb.com 
  8. return sprintf("8%x"$Result); 
  9. }

功能:获取pagerank

参数说明:$domain 网站域名,不包含"http://",代码如下:

  1. function pagerank($domain
  2. {  
  3. $StartURL = "http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank:&q=info:"
  4. // $StartURL = "http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:"; 
  5. $GoogleURL = $StartURL.$domain' &ch='.HashURL($domain); 
  6. $fcontents = file_get_contents"$GoogleURL"); 
  7. $pagerank = substr($fcontents,9);  
  8. if (!$pagerankreturn "0";else return $pagerank

OK,用php获取谷歌PR值算法,其实就这么简单,自己去测试下吧,上次,谷歌的PR值查询接口更改,上面的代码已经修改使用了谷歌PR查询的最新接口.

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表