本代码是一款站长常用工具了,用来查询google 收录代码,可以查询天
自定义天数
查询昨日收录情况
查询最近1星期收录情况
查询最近1月收录情况
查询最近2月收录情况
查询最近3月收录情况
查询最近6月收录情况
查询最近1年收录情况
查询总的(所有日期)收录情况
等信息。
function getpage($url)
{
$buf=parse_url($url);
if($buf['scheme']==http)//如果是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//如果是本地文件
{
$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));
}
对取得的google信息进行分析并且在本地。
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(,