首頁 >php教程 >php手册 >php获取网站google pr值的方法

php获取网站google pr值的方法

WBOY
WBOY原創
2016-06-06 19:56:13802瀏覽

欢迎进入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
\n”; //debug only

  $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] 

php获取网站google pr值的方法

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn