Php obtains the Google prvalue algorithm and php's prvalue query code.

Source: Internet
Author: User
Php obtains the Google prvalue algorithm and php's prvalue query code.

  1. /*
  2. * Function: encode the URL
  3. * Parameter description: $ web_url URL, which does not contain "http: //", for example, 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: obtain pagerank
  16. * Parameter description: $ domain website domain name, excluding "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. }

Note: Sometimes PR queries are slow, and many PR query sites have implemented various caches. In general, the prvalue will not change unless Google PR updates.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.