/*
* Function: encode the URL
* Parameter description: $ web_url URL, which does not contain "http: //", for example, 111cn.net
* Source: http://111cn.net
*/
| The code is as follows: |
Copy code |
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> 23) & 0x1FF) | $ Result <9;
}
Return sprintf ("8% x", $ Result );
}
|
/*
* Function: obtain pagerank
* Parameter description: $ domain website domain name, excluding "http ://",
* Source: http://111cn.net
| The code is as follows: |
Copy code |
*/
Function pagerank ($ domain)
{
$ StartURL = "http://toolbarqueries.google.com/tbr? Client = navclient-auto & features = Rank: & q = info :";
// $ StartURL = "http://www.google.com/search? Client = navclient-auto & features = Rank: & q = info :";
$ GoogleURL = $ StartURL. $ domain. '& ch ='. HashURL ($ domain );
$ Fcontents = file_get_contents ("$ GoogleURL ");
$ Pagerank = substr ($ fcontents, 9 );
If (! $ Pagerank) return "0"; else return $ pagerank;
} |
OK. Use php to obtain the Google prvalue algorithm. In fact, this is so simple. Test it by yourself. Last time, the prvalue query interface of Google was changed. The code above has been modified using the latest interface of Google PR query.