Maison  >  Article  >  développement back-end  >  PHP查询网站PR值的实现代码

PHP查询网站PR值的实现代码

WBOY
WBOYoriginal
2016-07-25 08:57:481024parcourir
  1. /*
  2. * 功能:对URL进行编码
  3. * 参数说明:$web_url 网站URL,不包含"http://"
  4. * site: bbs.it-home.org
  5. */
  6. function HashURL($url)
  7. {
  8. $SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
  9. $Result = 0x01020345;
  10. for ($i=0; $i {
  11. $Result ^= ord($SEED{$i%87}) ^ ord($url{$i});
  12. $Result = (($Result >> 23) & 0x1FF) | $Result }
  13. return sprintf("8%x", $Result);
  14. }
  15. /*
  16. *功能:根据google提供的pr查询接口获取pagerank
  17. *参数说明:$domain 网站域名,不包含"http://"
  18. */
  19. function pagerank($domain)
  20. {
  21. $StartURL = "http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank:&q=info:";
  22. $GoogleURL = $StartURL.$domain. '&ch='.HashURL($domain);
  23. echo $GoogleURL.'
    ';
  24. $fcontents = file_get_contents("$GoogleURL");
  25. $pagerank = substr($fcontents,9);
  26. if (!$pagerank) return "0";else return $pagerank;
  27. }
  28. echo pagerank("phpddt.com");
  29. ?>
复制代码


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn