欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php获取网站google pr值的方法

程序员文章站 2024-01-05 22:15:16
...

欢迎进入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值的方法

上一篇:

下一篇: