熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

Google PageRank PR值在線查詢php代碼

2013-11-15 12:27:08  來源: PHP編程 

  PR值全稱為PageRankPageRank(網頁級別)是Google用於評測一個網頁重要性的一種方法在揉合了諸如Title標識和Keywords標識等所有其它因素之後Google通過PageRank來調整結果使那些更具重要性的網頁在搜索結果中另網站排名獲得提升從而提高搜索結果的相關性和質量PR值最高為一般PR值達到就算是一個不錯的網站了

    PageRank是google搜索排名算法中的一個組成部分級別從級為滿分PR值越高說明該網頁在搜索排名中的地位越重要也就是說在其他條件相同的情況下PR值高的網站在google搜索結果的排名中有優先權

< ?php

// Edit this to your website url:
$myWebSite =
;

define(GMAG xEA);

//unsigned shift right
function zeroFill($a $b) {
$z = hexdec();

if ($z & $a) {
$a = ($a>>);
$a &= (~$z);
$a |= x;
$a = ($a>>($b));
} else {
$a = ($a>>$b);
}

return $a;
}


function mix($a$b$c) {

$a = $b; $a = $c; $a ^= (zeroFill($c));
$b = $c; $b = $a; $b ^= ($a< &lt;);
$c = $a; $c = $b; $c ^= (zeroFill($b));
$a = $b; $a = $c; $a ^= (zeroFill($c));
$b = $c; $b = $a; $b ^= ($a<&lt;);
$c = $a; $c = $b; $c ^= (zeroFill($b));
$a = $b; $a = $c; $a ^= (zeroFill($c));
$b = $c; $b = $a; $b ^= ($a<&lt;);
$c = $a; $c = $b; $c ^= (zeroFill($b));

return array($a$b$c);
}

function GCH($url $length=null $init=GMAG) {

if(is_null($length)) {
$length = sizeof($url);
}

$a = $b = xEB;
$c = $init;
$k = ;
$len = $length;

while($len >= ) {
$a += ($url[$k+] +($url[$k+]< &lt;) +($url[$k+]<&lt;) +($url[$k+]<&lt;));
$b += ($url[$k+] +($url[$k+]<&lt;) +($url[$k+]<&lt;) +($url[$k+]<&lt;));
$c += ($url[$k+] +($url[$k+]<&lt;) +($url[$k+]<&lt;)+($url[$k+]<&lt;));
$mix = mix($a$b$c);
$a = $mix[]; $b = $mix[]; $c = $mix[];
$k += ;
$len = ;
}

$c += $length;

switch($len) {/* all the case statements fall through */
case : $c+=($url[$k+]<&lt;);
case : $c+=($url[$k+]<&lt;);
case : $c+=($url[$k+]<&lt;);
/* the first byte of c is reserved for the length */
case : $b+=($url[$k+]<&lt;);
case : $b+=($url[$k+]<&lt;);
case : $b+=($url[$k+]<&lt;);
case : $b+=($url[$k+]);
case : $a+=($url[$k+]<&lt;);
case : $a+=($url[$k+]<&lt;);
case : $a+=($url[$k+]<&lt;);
case : $a+=($url[$k+]);
/* case : nothing left to add */
}

$mix = mix($a$b$c);
/* report the result */
return $mix[];
}

//converts a string into an array of integers containing the numeric value of the char
function strord($string) {

for($i=;$i<strlen($string);$i++) {
$result[$i] = ord($string{$i});
}

return $result;
}

function getPR($_url) {

$url = info:$_url;
$ch = GCH(strord($url));
$url=info:urlencode($_url);
$pr = file("$ch&ie=UTF&oe=UTF&features=Rank&q=$url");
$pr_str = implode("" $pr);

return substr($pr_strstrrpos($pr_str ":")+);
}

echo "<br>The PR of $myWebsite is: "getPR($myWebSite);
?>
  
 
From:http://tw.wingwit.com/Article/program/PHP/201311/20977.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.