- Регистрация
- 13.01.2009
- Сообщения
- 2 285
- Благодарностей
- 2 730
- Баллы
- 113
some magic ))
how to get Google PR of the page? the most hard part is to calculate hash of the URL.
Everything other is very simple.
This code generates URL to request Google Page Rank
how to get Google PR of the page? the most hard part is to calculate hash of the URL.
Everything other is very simple.
This code generates URL to request Google Page Rank
C#:
var url = project.Variables["url"].Value;
var myUri = new Uri(url);
string srUrl = myUri.AbsoluteUri;
// calc Google hash
string urlToHash = srUrl;
urlToHash = string.Format("info:{0}", urlToHash);
int length = urlToHash.Length;
UInt32 a, b;
UInt32 c = 0xE6359A60;
int k = 0;
int len = length;
a = b = 0x9E3779B9;
while (len >= 12)
{
a += (UInt32)(urlToHash[k + 0] + (urlToHash[k + 1] << 8) + (urlToHash[k + 2] << 16) + (urlToHash[k + 3] << 24));
b += (UInt32)(urlToHash[k + 4] + (urlToHash[k + 5] << 8) + (urlToHash[k + 6] << 16) + (urlToHash[k + 7] << 24));
c += (UInt32)(urlToHash[k + 8] + (urlToHash[k + 9] << 8) + (urlToHash[k + 10] << 16) + (urlToHash[k + 11] << 24));
a -= b; a -= c; a ^= c >> 13;
b -= c; b -= a; b ^= a << 8;
c -= a; c -= b; c ^= b >> 13;
a -= b; a -= c; a ^= c >> 12;
b -= c; b -= a; b ^= a << 16;
c -= a; c -= b; c ^= b >> 5;
a -= b; a -= c; a ^= c >> 3;
b -= c; b -= a; b ^= a << 10;
c -= a; c -= b; c ^= b >> 15;
k += 12;
len -= 12;
}
c += (UInt32)length;
switch (len)
{
case 11:
c += (UInt32)(urlToHash[k + 10] << 24);
goto case 10;
case 10:
c += (UInt32)(urlToHash[k + 9] << 16);
goto case 9;
case 9:
c += (UInt32)(urlToHash[k + 8] << 8);
goto case 8;
case 8:
b += (UInt32)(urlToHash[k + 7] << 24);
goto case 7;
case 7:
b += (UInt32)(urlToHash[k + 6] << 16);
goto case 6;
case 6:
b += (UInt32)(urlToHash[k + 5] << 8);
goto case 5;
case 5:
b += urlToHash[k + 4];
goto case 4;
case 4:
a += (UInt32)(urlToHash[k + 3] << 24);
goto case 3;
case 3:
a += (UInt32)(urlToHash[k + 2] << 16);
goto case 2;
case 2:
a += (UInt32)(urlToHash[k + 1] << 8);
goto case 1;
case 1:
a += urlToHash[k + 0];
break;
}
a -= b; a -= c; a ^= c >> 13;
b -= c; b -= a; b ^= a << 8;
c -= a; c -= b; c ^= b >> 13;
a -= b; a -= c; a ^= c >> 12;
b -= c; b -= a; b ^= a << 16;
c -= a; c -= b; c ^= b >> 5;
a -= b; a -= c; a ^= c >> 3;
b -= c; b -= a; b ^= a << 10;
c -= a; c -= b; c ^= b >> 15;
var checksum = string.Format("6{0}", c);
// generate Query URL
return string.Format("http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&ch={0}&features=Rank&q=info:{1}", checksum, System.Web.HttpUtility.UrlEncode(srUrl));
Вложения
-
18,4 КБ Просмотры: 530