PHP gets the PR value of the URL

Source: Internet
Author: User

The PR value is one of the most important criteria for Google to measure the site, according to Google's results to obtain the PR value, such as:
Http://toolbarqueries.google.com.hk/tbr?client=navclient-auto&features=Rank:&q=info:phpddt.com&ch= 8fabc62ea

<?php

*
* Function: Code URL encoding
* parameter description: $web _url Web site URL, does not contain "http://
"
/function Hashurl ($url)
{   
    $SEED = "Mining PageRank is against GOOGLE ' S TERMS of SERVICE. Yes, I ' m talking to you, scammer. "
    $Result = 0x01020345;
    For ($i =0 $i <strlen ($url); $i + +) 
    {
        $Result ^= ord ($SEED {$i%87}) ^ ord ($url {$i}
        ); $Result = (($Result >>) & 0x1ff)  $Result << 9;
    }
    Return sprintf ("8%x", $Result);
}
* * Function: According to Google's PR query interface to obtain PageRank
* parameter description: $domain site domain name, does not include "http://"
/function PageRank ($ Domain)
{    
    $StartURL = "Http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank: &q=info: ";
    $GoogleURL = $StartURL. $domain. ' &ch= '. Hashurl ($domain);
    echo $GoogleURL. ' <br> ';
    $fcontents = file_get_contents ("$GoogleURL");
    $pagerank = substr ($fcontents, 9);
    if (! $pagerank) Return of "0"; else return $pagerank;
}
echo PageRank ("phpddt.com");
? >


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.