<option value= "1" > Custom days </option>
<option value= "D" > Query yesterday included situation </option>
<option value= "W" > Enquiries about the last 1 weeks included </option>
<option value= "M" > Enquiries on the recent January collection </option>
<option value= "M2" > enquiries on the recent February collection </option>
<option value= "M3" > enquiries on the recent March collection </option>
<option value= "M6" > Enquiries on the recent June collection </option>
<option value= "Y" > Inquire about the latest 1 years of collection </option>
<option value= "All" > Query total (all dates) included information </option>
and other information.
function GetPage ($url)
{
$buf =parse_url ($url);
if ($buf [' scheme ']== ' http ')//If it is a URL
{
$host = $buf [' Host '];
$page = $buf [' path '];
if (the 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));
}
Analysis of the obtained Google information and 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, "<div id=res class=med>", "<div ID=BSF style");
$TheBody =iconv ("UTF-8", "Gb2312//ignore", $TheBody);
$TheBody =str_replace ("<!--z--><p><i>", "<!--z--><!--<p><i>", $TheBody);
$TheBody =str_replace (' <br clear= ' all '/> ', ' <br clear= ', ' All '/> ', $TheBody);
$TheBody =preg_replace (' <a href= '/search?num=20 (. +?) Amp;as_qdr= (. +?) &q=site: (. +?) &start= (. +?) &sa=n ">", ' a href=?q=$3&t=$2&p=$4> <!--z--', $ Thebody);
$TheBody =str_replace ("The site may contain malicious software that could harm your computer." "," ", $TheBody);
$TheBody =str_replace ("/interstitial?url=", "", $TheBody);
$TheBody =str_replace ("-<nobr>", "", $TheBody);
$TheBody =str_replace ("Similar page", "", $TheBody);
$total =getcontent ($TheThie, "</b></div><p>", "</b>-<b>");
$total =iconv ("UTF-8", "Gb2312//ignore", $total);
$total =getcontent ($total, "<b>", "</b>");
$total =str_replace ("<b>", "", $total);
$total =str_replace (",", "", $total);
$total =intval ($total);