Prvalue is one of the important criteria for google to measure the website. Today, we will give you a method to query the prvalue of a website using PHP. The prvalue is one of the important criteria for google to measure the website. The prvalue is obtained based on the results provided by google, such:
Http://toolbarqueries.google.com.hk/tbr? Client = navclient-auto & features = Rank: & q = info: phpddt.com & ch = 8fabc62ea
The Code is as follows:
/*
* Function: encode the URL
* Parameter description: $ web_url URL, excluding "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 {
$ Result ^ = ord ($ SEED {$ I % 87}) ^ ord ($ url {$ I });
$ Result = ($ Result> 23) & 0x1FF) | $ Result <9;
}
Return sprintf ("8% x", $ Result );
}
/*
* Function: Obtain pagerank Based on the pr query interface provided by google.
* Parameter description: $ domain website domain name, excluding "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 .'
';
$ Fcontents = file_get_contents ("$ GoogleURL ");
$ Pagerank = substr ($ fcontents, 9 );
If (! $ Pagerank) return "0"; else return $ pagerank;
}
Echo pagerank ("phpddt.com ");
?>