Google search and pr search php source code download _ PHP Tutorial

Source: Internet
Author: User
Google search and pr search php source code download. This content is to download the php source code from google's indexed query and pr query. you can use it with a slight modification after the download. This is a query of google indexed queries and pr queries. this is a query of google indexed queries and pr queries for php source code download. you can use it with a slight modification after the download.

This content is to download the php source code from google's indexed query and pr query. you can use it with a slight modification after the download.

Function google ()
{
// Scan Google search results too frequently at the same time, and GG will block this IP address. Therefore, glaciers temporarily remove this function
// If you want to enable this function, you can add comments to the following line. thank you!
Echo "0"; return "";
Global $ murl, $ furl;
$ Url = "http://www.google.cn/search? Hl = zh-CN & q = site: $ furl ";
$ Page = file_get_contents ($ url );
// Echo $ page;
$ PageNum = "0 ";
$ PageNum = str_replace (",", "", cut ($ page ,"

About","Items comply "));
If ($ PageNum = "") $ PageNum = "0 ";
Echo "$ PageNum ";
}

Function pr ()
{
Global $ murl, $ furl;
Echo GetPR ("http: // $ furl ");
}

Function cut ($ string, $ start, $ end)
{
$ Message = explode ($ start, $ string );
$ Message = explode ($ end, $ message [1]);
Return $ message [0];
}

// Functions are the same as escape in javascript
Function escape ($ str ){
Preg_match_all ("/[x80-xff]. | [x01-x7f] +/", $ str, $ r );
$ Ar = $ r [0];
Foreach ($ ar as $ k => $ v ){
If (ord ($ v [0]) <128)
$ Ar [$ k] = rawurlencode ($ v );
Else
$ Ar [$ k] = "% u". bin2hex (iconv ("GB2312", "UCS-2", $ v ));
}
Return join ("", $ ar );
}

Function unescape ($ str ){
$ Str = rawurldecode ($ str );
Preg_match_all ("/(? : % U. {4}) |. +/", $ str, $ r );
$ Ar = $ r [0];
Foreach ($ ar as $ k => $ v ){
If (substr ($ v, 0, 2) = "% u" & strlen ($ v) = 6)
$ Ar [$ k] = iconv ("UCS-2", "GB2312", pack ("H4", substr ($ v,-4 )));
}
Return join ("", $ ar );
}


// The following function is used to query pr
Function zeroFill ($ a, $ B)
{
$ Z = hexdec (80000000 );
If ($ z & $)
{
$ A = ($ a> 1 );
$ A & = (~ $ Z );
$ A | = 0x40000000;
$ A = ($ a >>( $ B-1 ));
}
Else
{
$ A = ($ a >>$ B );
}
Return $;
}

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)
{
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 $ Result [$ I] = ord ($ string {$ I });
}
Return $ result;
}

Function ReadPR ($ link)
{
$ Fp = fsockopen ("www.google.com", 80, $ errno, $ errstr, 30 );
If (! $ Fp)
{
Echo "$ errstr ($ errno) n ";
Exit (1 );
}
Else
{
$ Out = "GET $ link HTTP/1.0rn ";
$ Out. = "Host: toolbarqueries. google. comrn ";
$ Out. = "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114.9-big; Linux 2.6) rn ";
$ Out. = "Connection: Closernrn ";
Fwrite ($ fp, $ out );
Do {
$ Line = fgets ($ fp, 128 );
} While ($ line! = "Rn ");
$ Data = fread ($ fp, 8192 );
Fclose ($ fp );
Return $ data;
}
}

Function GetPR ($ url)
{
$ Url = 'info: '. $ url;
$ Ch = GoogleCH (strord ($ url ));
$ Data = ReadPR ("/search? Client = navclient-auto & ch = 6 $ ch & features = Rank & q = $ url ");
$ Rankarray = explode (':', $ data );
If (trim ($ rankarray [2])! = ""){
Return $ rankarray [2];
}
Else
Return "0 ";
}


Download the php source code for indexing queries and pr queries. you can use it with a slight modification after the download. This article is a google search and pr query...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.