This code is a commonly used webmaster tool, used to query google indexed code, can query days this code is a commonly used webmaster tool, used to query google indexed code, can query days
Script ec (2); script
Custom days
Query yesterday's records
Query the records of the last week
Query the records recorded in the last month
Query the records recorded in the last month
Query the records recorded in the last month
Query the records recorded in the last month
Query the indexing status in the last year
Query the total (ALL dates) records
.
Function GetPage ($ url)
{
$ Buf = parse_url ($ url );
If ($ buf ['scheme '] = "http") // if it is a URL
{
$ Host = $ buf ['host'];
$ Page = $ buf ['path'];
If (trim ($ buf ['query'])! = "") $ Page. = "? ". Trim ($ buf ['query']);
$ MyHeader = "GET $ url HTTP/1.1rn ";
$ MyHeader. = "Host: $ hostrn ";
$ MyHeader. = "Connection: closern ";
$ MyHeader. = "Accept: text/xml, application/xml, application/xhtml + xml, text/html; q = 0.9, text/plain; q = 0.8, image/png, */*; q = 0.5rn ";
$ MyHeader. = "Accept-Language: zh-cn, zh; q = 0.5rn ";
$ MyHeader. = "Accept-Charset: gb2312, UTF-8; q = 0.7, *; q = 0.7rn ";
$ MyHeader. = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv: 1.7.6) Gecko/20050226 Firefox/1.0.1 Web-Sniffer/1.0.20rn ";
$ MyHeader. = "Referer: http: // $ host/rnrn ";
$ Server = $ host;
$ Port = 80;
$ Res = "";
If (false! ==( $ Fp = @ fsockopen ($ server, $ port, $ errno, $ errstr, 30 )))
{
@ Fputs ($ fp, $ myHeader );
While (! @ Feof ($ fp) $ res. = @ fgets ($ fp, 1024 );
@ Fclose ($ fp );
}
Else return false;
If (strlen ($ res) = 0) return false;
Return $ res;
}
Else // if it is a local file
{
$ FileName = $ url;
If (false! ==@ File_exists ($ fileName ))
{
If (false! ==( $ Buf = @ implode ("", file ($ fileName) & @ strlen ($ buf)> 0)
{
Return $ buf;
}
Else return false;
}
Else return false;
}
}
Function GetContent ($ str, $ x, $ y ){
$ Tem = strstr ($ str, $ x );
Return substr ($ tem, 0, strpos ($ tem, $ y ));
}
Analyze the obtained google information and make it local.
If (isset ($ q ))
{
$ TheUrl = "http://www.google.cn/search? Q = + site :". $ q. "& num = 20 & complete = 1 & hl = zh-CN & lr = & newwindow = 1 & as_qdr = ". $ t. "& start = ". $ p. "& sa = N ";
$ TheThie = GetPage ($ TheUrl );
}
$ TheBody = GetContent ($ TheThie ,"
","
$ TheBody = iconv ("UTF-8", "gb2312 // IGNORE", $ TheBody );
$ TheBody = str_replace ("
","