Categories


Tags


Google PageRank的计算源代码

最近对google的PageRank(网页等级)比较感兴趣,一直想知道如何不用google toolbar来获取pr值。苦苦搜索之后,找到如下代码:

<?php

/**

This code is released unto the public domain

*/

//header("Content-Type: text/plain; charset=utf-8");

define('GOOGLE_MAGIC', 0xE6359A60);

//unsigned shift right

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=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 = mix($a,$b,$c);

$a = $mix[0]; $b = $mix[1]; $c = $mix[2];

$k += 12;

$len -= 12;

}

$c += $length;

switch($len)              /* all the case statements fall through */

{

case 11: $c+=($url[$k+10]<<24);

case 10: $c+=($url[$k+9]<<16);

case 9 : $c+=($url[$k+8]<<8);

/* the first byte of c is reserved for the length */

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]);

/* case 0: nothing left to add */

}

$mix = mix($a,$b,$c);

/*-------------------------------------------- report the result */

return $mix[2];

}

//converts a string into an array of integers containing the numeric value of the char

function strord($string) {

for($i=0;$i<strlen($string);$i++) {

$result[$i] = ord($string{$i});

}

return $result;

}

// http://www.example.com/ - Checksum: 6540747202

$url = 'info:'.$_GET['url'];

$ch = GoogleCH(strord($url));

$url='info:'.urlencode($_GET['url']);

echo file_get_contents("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url");

/* use curl send the user angent

$curl = curl_init("http://www.google.com/search?client=navclient-auto&ch=6$ch&ie=UTF-8&oe=UTF-8&features=Rank&q=$url");

curl_setopt ($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; GoogleToolbar 2.0.110-big; Windows 2000 5.0)");

curl_exec($curl);

*/

?>

</></>

来源:月光博客


Public @ 2022-12-07 15:39:09

Sogou Rank与网页排名关系研究

最近对网站和域名的综合权威度或重要性感受比较多,所以robin一告诉我Sogou Rank推出的消息就很感兴趣。今天来做个简单的研究比较,看看Sogou Rank和真正的网页排名之间的关系。我随机挑一个关键词在Sogou,百度,Google做搜索,看排在前十名的网页Sogou Rank是多少。为排除大型门户或知名服务商网站传递给二级域名及分目录的重要性,将这些结果删除,只看独立的专门的网站。关键词

Public @ 2013-01-05 15:39:02

Google PR 值是什么?怎样计算?

相信对SEO感兴趣的人,都听说过Google PR值,英文全称是PageRank,缩写为PR,中文通常称为网页级别。所谓Google PR,是由 Google的两位创始人Larry Page 和 Sergey Brin 在斯坦福大学开发的衡量网页重要性的一个指标。朴素的思路是,一个网页导入链接越多,页面应该就更重要,所以PR值就越高。PR可以理解为页面之间的投票行为,网页A链接到网页B时,Goog

Public @ 2018-11-18 15:39:03

Google PageRank(网页级别)介绍

Google的核心软件称为 PageRank(网页级别),这是由Google创始人 Larry Page 和 Sergey Brin 在斯坦福大学开发出的一套用于网页评级的系统,网页级别是所有Google网络搜索工具的基础。作为组织管理工具,网页级别利用了互联网独特的民主特性及其巨大的链接结构。实质上,当从网页 A 链接到网页 B 时,Google 就认为"网页 A 投了网页 B 一票&

Public @ 2012-10-28 15:39:07

更多您感兴趣的搜索

0.432455s