欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 //return the pagerank checksum hash function getch($url) { return CheckHash(HashURL($url)); } //return the pagerank figure function getpr($url) { global $googlehost,$googleua;
欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入
//return the pagerank checksum hash
function getch($url) { return CheckHash(HashURL($url)); }
//return the pagerank figure
function getpr($url) {
global $googlehost,$googleua;
$pr = 0; // default return
$ch = getch($url);
$fp = fsockopen($googlehost, 80, $errno, $errstr, 30);
if ($fp) {
$out = "GET /search?client=navclient-auto&ch=$ch&features=Rank&q=info:$url HTTP/1.1\r\n";
//echo “
$out
$out .= “User-Agent: $googleua\r\n”;
$out .= “Host: $googlehost\r\n”;
$out .= “Connection: Close\r\n\r\n”;
fwrite($fp, $out);
//$pagerank = substr(fgets($fp, 128), 4); //debug only
//echo $pagerank; //debug only
while (!feof($fp)) {
$data = fgets($fp, 128);
//echo $data;
$pos = strpos($data, “Rank_”);
if($pos === false){} else{
$pr=substr($data, $pos + 9);
$pr=trim($pr);
$pr=str_replace(“\n”,”,$pr);
return $pr;
}
}
//else { echo “$errstr ($errno) \n”; } //debug only
fclose($fp);
}
return $pr;
}
?>
[1] [2]