Home > php教程 > php手册 > body text

php获取网站google pr值的方法

WBOY
Release: 2016-06-06 19:56:13
Original
782 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template