Home  >  Article  >  Backend Development  >  PHP obtains Google PR value algorithm and PHP query PR value code

PHP obtains Google PR value algorithm and PHP query PR value code

WBOY
WBOYOriginal
2016-07-25 08:57:431210browse
  1. /*
  2. *Function: Encode URL
  3. *Parameter description: $web_url website URL, does not contain "http://", such as jbxue.com
  4. */
  5. function HashURL( $url){
  6. $SEED = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
  7. $Result = 0x01020345;
  8. for ($i=0; $i{
  9. $Result ^= ord($SEED{$i%87}) ^ ord($url{$i});
  10. $Result = (($Result >> 23) & 0x1FF) | $Result << 9;
  11. }
  12. return sprintf("8%x", $Result);
  13. }
  14. /*
  15. *Function: Get pagerank
  16. *Parameter description: $domain website domain name, not Contains "http://",
  17. */
  18. function pagerank($domain)
  19. {
  20. $StartURL = "http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank:&q=info:" ;
  21. // $StartURL = "http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:";
  22. $GoogleURL = $StartURL.$domain. '&ch='.HashURL ($domain);
  23. $fcontents = file_get_contents("$GoogleURL");
  24. $pagerank = substr($fcontents,9);
  25. if (!$pagerank) return "0";else return $pagerank;
  26. }
Copy code

Instructions: PR queries are sometimes a bit slow. Many PR query sites have various caches. Under normal circumstances, the PR value will not change unless Google PR is updated.



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