专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »PHP教程 » 爬虫代码:实现蜘蛛捕捉的PHP代码 (WEB爬虫) »正文

爬虫代码:实现蜘蛛捕捉的PHP代码 (WEB爬虫)

来源: 发布时间:星期一, 2009年1月12日 浏览:77次 评论:0
function get_naps_bot
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
(strpos($useragent, 'googlebot') ! false){
'Googlebot';
}
(strpos($useragent, 'msnbot') ! false){
'MSNbot';
}
(strpos($useragent, 'slurp') ! false){
'Yahoobot';
}
(strpos($useragent, 'baiduspider') ! false){
'Baiduspider';
}
(strpos($useragent, 'sohu-search') ! false){
'Sohubot';
}
(strpos($useragent, 'lycos') ! false){
'Lycos';
}
(strpos($useragent, 'robozilla') ! false){
'Robozilla';
}
false;
}
function nowtime{
$date=date("Y-m-d.G:i:s");
$date;
}
$searchbot = get_naps_bot;
($searchbot) {
$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
$url=$_SERVER['HTTP_REFERER'];
$file="robotlog.txt";
$time=nowtime;
$data=fopen($file,"a");
fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage ");
fclose($data);
}


0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: