Не думал, что придется когда-нибудь писать такую шняжку... Вообще надо на неком сайте через форму узнавать PR. Кто-нибудь знает, если ли сервис на подобие http://search.yaca.yandex.ru/yca/cy/ch/php.ru/ , но только от гугла. Вообще как можно узнать RP не юзая гуглбар? Есть мысли?
вся сложность получения информации по ПР от гугла состоит в том, что в ссылке передается контрольная сумма, расчитываемая с участием урла. когда то давно часть тасчета этой проверки выглядело так: Код (Text): function GoogleChecksum(Value: TDynByteArray): Integer; const GOOGLE_MAGIC = $E6359A60; var I: Integer; A, B, C, K, Len: Integer; begin A := $9E3779B9; B := $9E3779B9; C := GOOGLE_MAGIC; K := 0; Len := Length(Value); while Len >= 12 do begin A := AddEx(A, AddEx(Value[k], AddEx((Value[k + 1] shl 8), AddEx((Value[k + 2] shl 16), (Value[k + 3] shl 24))))); B := AddEx(B, AddEx(Value[k + 4], AddEx((Value[k + 5] shl 8), AddEx((Value[k + 6] shl 16), (Value[k + 7] shl 24))))); C := AddEx(C, AddEx(Value[k + 8], AddEx((Value[k + 9] shl 8), AddEx((Value[k + 10] shl 16), (Value[k + 11] shl 24))))); Mix(A, B, C); Inc(K, 12); Dec(Len, 12); end; C := AddEx(C, Length(Value)); if Len > 10 then C := AddEx(C, Value[K + 10] shl 24); if Len > 9 then C := AddEx(C, Value[K + 9] shl 16); if Len > 8 then C := AddEx(C, Value[K + 8] shl 8); if Len > 7 then B := AddEx(B, Value[K + 7] shl 24); if Len > 6 then B := AddEx(B, Value[K + 6] shl 16); if Len > 5 then B := AddEx(B, Value[K + 5] shl 8); if Len > 4 then B := AddEx(B, Value[K + 4]); if Len > 3 then A := AddEx(A, Value[K + 3] shl 24); if Len > 2 then A := AddEx(A, Value[K + 2] shl 16); if Len > 1 then A := AddEx(A, Value[K + 1] shl 8); if Len > 0 then A := AddEx(A, Value[K]); Mix(A, B, C); Result := C; end; не страшно? а вот сейчас они что то там изменили, и лень заново все выковаривать...
PHP: <?php function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); } else { $a = ($a>>$b); } return $a; } function mix($a,$b,$c) { $a -= $b; $a -= $c; $a ^= (zeroFill($c,13)); $b -= $c; $b -= $a; $b ^= ($a<<8); $c -= $a; $c -= $b; $c ^= (zeroFill($b,13)); $a -= $b; $a -= $c; $a ^= (zeroFill($c,12)); $b -= $c; $b -= $a; $b ^= ($a<<16); $c -= $a; $c -= $b; $c ^= (zeroFill($b,5)); $a -= $b; $a -= $c; $a ^= (zeroFill($c,3)); $b -= $c; $b -= $a; $b ^= ($a<<10); $c -= $a; $c -= $b; $c ^= (zeroFill($b,15)); return array($a,$b,$c); } function GoogleCH($url, $length=null, $init=0xE6359A60) { if(is_null($length)) { $length = sizeof($url); } $a = $b = 0x9E3779B9; $c = $init; $k = 0; $len = $length; while($len >= 12) { $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24)); $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24)); $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24)); $mix = mix($a,$b,$c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch($len) { case 11: $c+=($url[$k+10]<<24); case 10: $c+=($url[$k+9]<<16); case 9 : $c+=($url[$k+8]<<8); case 8 : $b+=($url[$k+7]<<24); case 7 : $b+=($url[$k+6]<<16); case 6 : $b+=($url[$k+5]<<8); case 5 : $b+=($url[$k+4]); case 4 : $a+=($url[$k+3]<<24); case 3 : $a+=($url[$k+2]<<16); case 2 : $a+=($url[$k+1]<<8); case 1 : $a+=($url[$k+0]); } $mix = mix($a,$b,$c); return $mix[2]; } function strord($string) { for($i=0;$i<strlen($string);$i++) { $result[$i] = ord($string{$i}); } return $result; } function get_pr($url) { $result=array("",-1); if(($url.""!="")&&($url.""!="http://")): if(substr(strtolower($url),0,7)!="http://"): $url="http://".$url; endif; $url="info:".$url; $checksum=GoogleCH(strord($url)); $google_url=sprintf("http://www.google.com/search?client=navclient-auto&ch=6%u&features=Rank&q=".$url,$checksum); $contents = file_get_contents($google_url); $p=explode(":",$contents); if(isset($p[2])): $result[1]=$p[2]; endif; endif; return $result; } function getPR_url($url) { global $db; if(eregi('^http://www.',$url)) { $url_www = str_replace('http://www.','http://',$url); } else { $url_www = str_replace('http://','http://www.',$url); } $pr=get_pr($url); $output=$pr[0]; $pagerank=$pr[1]; sleep(1); $pr=get_pr($url_www); $output_www=$pr[0]; $pagerank_www=$pr[1]; if($pagerank<$pagerank_www) { $pagerank=$pagerank_www; } if($pagerank==-1) { $pagerank=0; } return intval($pagerank); } echo getPR_url('www.google.com'); ?> Кто написал код - хз.
Спасибо за варианты. Дополню кодом, как узнать тИЦ, автор Жилинский Владимир. PHP: <?php function yandex_tic($url){ $file=file_get_contents("http://search.yaca.yandex.ru/yca/cy/ch/$url/"); if(preg_match("!—\s+([0-9]{0,8})<\/b>!is",$file,$ok)){ $str=$ok[1]; } else if(preg_match("!<td class=\"current\" valign=\"middle\">(.*?)</td>\n</tr>!si", $file, $ok)){ if(preg_match("!<td align=\"right\">(.*?)</td>\n</tr>!si", $ok[0], $str)){ $str=$str[1]; } else { $str=0; } } else { $str=0; } return trim($str); } echo yandex_tic("ya.ru") Не юзал. Но если даже не работает, суть, как можно сделать, на ладони.
http://pr-cy.ru - Один из сервисов для узнавания тИЦ и PR. Вообще дата центров полно, около 70 штук более менее надежных, списки надо искать на SEO-форумах. И выложу тоже свой скрипт определения PR (им со мной любезно поделился один из участников форума, не помню кто): Код (Text): //Получения PageRank $pr = get_pr($website); function ($Str, $Check, $Magic) { $Int32Unit = 4294967296; // 2^32 $length = strlen($Str); for ($i = 0; $i < $length; $i++) { $Check *= $Magic; //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31), // the result of converting to integer is undefined // refer to http://www.php.net/manual/en/language.types.integer.php if ($Check >= $Int32Unit) { $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit)); //if the check less than -2^31 $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check; } $Check += ord($Str{$i}); } return $Check; } /* * Genearate a hash for a url */ function HashURL($String) { $Check1 = StrToNum($String, 0x1505, 0x21); $Check2 = StrToNum($String, 0, 0x1003F); $Check1 >>= 2; $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F); $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF); $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF); $T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F ); $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 ); return ($T1 | $T2); } /* * genearate a checksum for the hash string */ function CheckHash($Hashnum) { $CheckByte = 0; $Flag = 0; $HashStr = sprintf('%u', $Hashnum) ; $length = strlen($HashStr); for ($i = $length - 1; $i >= 0; $i --) { $Re = $HashStr{$i}; if (1 === ($Flag % 2)) { $Re += $Re; $Re = (int)($Re / 10) + ($Re % 10); } $CheckByte += $Re; $Flag ++; } $CheckByte %= 10; if (0 !== $CheckByte) { $CheckByte = 10 - $CheckByte; if (1 === ($Flag % 2) ) { if (1 === ($CheckByte % 2)) { $CheckByte += 9; } $CheckByte >>= 1; } } return '7'.$CheckByte.$HashStr; } function get_pr($href) { global $prs; if (isset($prs[$href])) return $prs[$href]; elseif (strpos($href, '&') !== false) return $prs[$href] = 0; // Берём PR $tq_servers = array('72.14.221.99', '72.14.221.100', '72.14.221.101', '72.14.221.102', '64.233.161.19', '64.233.161.99', '64.233.163.189', '64.233.171.44', '64.233.171.101', '64.233.183.99', '64.233.183.147', '64.233.185.19', '64.233.185.84', '64.233.185.133', '66.102.9.107', '66.102.11.115', '66.249.81.84', '66.249.81.101', '66.249.89.83', '72.14.203.19', '72.14.205.44', '72.14.207.19', '72.14.209.104', '209.85.143.84', '216.239.59.17', '216.239.59.81'); $url = 'http://'.$tq_servers[array_rand($tq_servers)].'/search?client=navclient-auto&ch='.CheckHash(HashURL($href)).'&features=Rank:&q=info:'.$href; $success = false; $counter = 0; while ($success == false) { if ($counter == 15) return $prs[$href] = 0; $counter ++; $php_errormsg = ''; $text = file_get_contents($url); if (!isset($php_errormsg)) $php_errormsg = ''; if (strpos($php_errormsg, 'HTTP/1.0 403') !== false) $text = 'Rank_1:1:0'; if ($text != "") $success = true; $php_errormsg = ''; } $text = str_replace(array("\n", "\r"), '', $text); preg_match("|Rank_[0-9]+\:[0-9]+\:([0-9]+)|i", $text, $matches2); $prs[$href] = intval($matches2[1]); return intval($matches2[1]); } Но при этом, вроде, любой скрипт определения PR имеют какой-то процент ошибки.
Так себе скрипт, траффика будет жрать нехило, лучше через bar-nagiv.yandex.ru Помоему, этот будет побыстрее: Код (Text): function get_cy($href) { $url = 'http://bar-navig.yandex.ru/u?ver=3&show=3&url=' . $href; $text = file_get_contents($url); preg_match("/<tcy rang="[0-9]" value="([0-9]+)/", $text, $matches2); return $matches2[1]; }