Home  >  Article  >  php教程  >  php获取网站google pr值的方法

php获取网站google pr值的方法

WBOY
WBOYOriginal
2016-06-06 19:56:13753browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP开发中常用到一些技巧Next article:PHP?????程?算?