![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 184 Pomógł: 6 Dołączył: 23.02.2008 Skąd: Katowice Ostrzeżenie: (0%) ![]() ![]() |
Witam, probuje sprawdzić pagerank strony w google z poziomu skrypt, mam coś takiego :
Kod <?php define('GOOGLE_MAGIC', 0x00000000E6359A60); // CHANGED (64Bit) class google_pr { var $checksum; function google_pr(){ $this->checksum=''; } 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; $this->toInt32($a); $a = (int)($a ^ ($this->zeroFill($c,13))); $b -= $c; $b -= $a; $this->toInt32($b); $b = (int)($b ^ ($a<<8)); $c -= $a; $c -= $b; $this->toInt32($c); $c = (int)($c ^ ($this->zeroFill($b,13))); $a -= $b; $a -= $c; $this->toInt32($a); $a = (int)($a ^ ($this->zeroFill($c,12))); $b -= $c; $b -= $a; $this->toInt32($b); $b = (int)($b ^ ($a<<16)); $c -= $a; $c -= $b; $this->toInt32($c); $c = (int)($c ^ ($this->zeroFill($b,5))); $a -= $b; $a -= $c; $this->toInt32($a); $a = (int)($a ^ ($this->zeroFill($c,3))); $b -= $c; $b -= $a; $this->toInt32($b); $b = (int)($b ^ ($a<<10)); $c -= $a; $c -= $b; $this->toInt32($c); $c = (int)($c ^ ($this->zeroFill($b,15))); return array($a,$b,$c); } function strord($string) { for($i=0;$i<strlen($string);$i++) { $result[$i] = ord($string{$i}); } return $result; } function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) { 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 = $this->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 = $this->mix($a,$b,$c); return $mix[2]; } function getGoogleChecksum($url) { $url="info:"."http://".str_replace('http://','',$url); $tmp_ch=$this->strord($url); $this->checksum=sprintf("%u", $this->GoogleCH($tmp_ch)); return $this->checksum; } function toInt32(& $x) { $z = hexdec(80000000); $y = (int)$x; if($y==-$z&&$x<-$z){ $y = (int)((-1)*$x); $y = (-1)*$y; } $x = $y; } function get_page_rank($url){ $reqgr = "info:".$url; $reqgre = "info:".urlencode($url); $gch="6".$this->getGoogleChecksum($url); $patern = '/^http:/'; $patern2 = '/^http:\/\/.*google\..*\/(search|images|groups|news).*/'; $patern3 = '/^http:\/\/localhost.*/'; $patern4 = '/^http:\/\/(127\.|10\.|172\.16|192\.168).*/'; //local ip if(!preg_match($patern, $url) || preg_match($patern2, $url) || preg_match($patern3, $url) || preg_match($patern4, $url)){ return -1; } else { $website = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=".$gch."&ie=UTF-8&oe=UTF-8&features=Rank&q=".$reqgre; if(!$ch = curl_init($website)) { return 'Count not connect to google.com'; } curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; GoogleToolbar 3.0.114-big; Windows XP 5.1)'); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $res['content'] = curl_exec($ch); curl_close ($ch); if(preg_match('/Rank_.*?:.*?:(\d+)/i', $res['content'], $m)) { return $m[1]; } else { return 0; } } } } ?> Wywoluje to tak : $pr = new google_pr; echo $pr->get_page_rank('url.pl'); skrypt pokazuje pr "-1" lub 0 - nawet gdy jest np 5moze macie inne skrypty lub wskazania ? Ten post edytował crackcomm 24.03.2008, 19:06:03 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 17 Pomógł: 0 Dołączył: 22.07.2007 Ostrzeżenie: (0%) ![]() ![]() |
mozna by sie zastanowic czy 0 i 1 to nie prawda i falsz, udalo sie i nie
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 102 Pomógł: 22 Dołączył: 3.03.2008 Ostrzeżenie: (0%) ![]() ![]() |
Ja używam google_pagerank.class z http://code.google.com/p/popstats/, ale miałem też kiedyś inną klasę z http://www.phpclasses.org. Obie działały bezproblemowo - tylko pamiętaj że na raz możesz maks około 1000 zapytań do googla wysłać, później zawsze będzie zwracał 0 lub -1 (zależy co będziesz miał ustawione) - bo google nie lubi takich automatów i wyskoczy captcha i automat nie otrzyma wyników. Musisz pamiętać że jest kilka opcji wyskoczenia takiego czegoś (0 lub -1):
- strona nie ma jeszcze PR - strona ma PR = 0 - tymczasowy ban od googla - czyli captcha - podałeś błędny adres i nie można pobrać dla takiego PR... Ten post edytował oscar17 24.03.2008, 23:46:10 |
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 184 Pomógł: 6 Dołączył: 23.02.2008 Skąd: Katowice Ostrzeżenie: (0%) ![]() ![]() |
ok pogrzebie w tym (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
EDIT: dzięki za te linki już działa Ten post edytował crackcomm 25.03.2008, 11:42:28 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 23.08.2025 - 10:41 |