PHP获取网页源代码内容

php可以用几个函数来采集网页的源代码,晚上无聊写了一份查看搜索引擎收录情况的代码,只是简单写了下并没有做什么处理,把代码贴上面留日后查看。
 function baidu($s,$t){
 $baidu=”http://www.baidu.com/s?wd=site%3A”.$s.”&lm=”.$t;
 $site=file_get_contents($baidu);
 $site=iconv(“gb2312”, “UTF-8”, $site);
 ereg(“相关网页(.*)篇”, $site, $count);
 $count=str_replace(“相关网页”,””,$count);
 $count=str_replace(“篇”,””,$count);
 $count=str_replace(“约”,””,$count);
 return $count[0];
 } 
 function google($s,$t){
 $google=”http://www.google.cn/search?q=site%3A”.$s.”&as_qdr=”.$t;
 $site=file_get_contents($google);
 $site=iconv(“gb2312”, “UTF-8”, $site);
 ereg(“约有 <b>(.*)</b> 项符合”, $site, $count);
 $count=str_replace(“约有 <b>”,””,$count);
 $count=str_replace(“</b> 项符合”,””,$count);
 return $count[0];
 }

0 0 投票数
文章评分
订阅评论
提醒
guest

0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x