Home  >  Article  >  Backend Development  >  PHP implementation code for querying website PR value

PHP implementation code for querying website PR value

WBOY
WBOYOriginal
2016-07-25 08:57:481054browse
  1. /*
  2. * Function: Encode URL
  3. * Parameter description: $web_url website URL, does not contain "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 << 9;
  13. }
  14. return sprintf("8%x", $Result);
  15. }
  16. /*
  17. *Function: query based on pr provided by google Interface to obtain pagerank
  18. * Parameter description: $domain website domain name, does not include "http://"
  19. */
  20. function pagerank($domain)
  21. {
  22. $StartURL = "http://toolbarqueries.google.com/tbr? client=navclient-auto&features=Rank:&q=info:";
  23. $GoogleURL = $StartURL.$domain. '&ch='.HashURL($domain);
  24. echo $GoogleURL.'
    ';
  25. $fcontents = file_get_contents("$GoogleURL");
  26. $pagerank = substr($fcontents,9);
  27. if (!$pagerank) return "0";else return $pagerank;
  28. }
  29. echo pagerank("phpddt.com") ;
  30. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn