文件名称:实现蜘蛛捕捉的PHP代码
文件大小:13KB
文件格式:DOC
更新时间:2014-01-07 13:33:42
爬虫 实现蜘蛛捕捉的 PHP代码
实现蜘蛛捕捉的PHP代码 实现蜘蛛捕捉的PHP代码如下: 张敏BLOG MP4下载 function get_naps_bot() { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); if (strpos($useragent, 'googlebot') !== false){ return 'Googlebot'; } if (strpos($useragent, 'msnbot') !== false){ return 'MSNbot'; } if (strpos($useragent, 'slurp') !== false){ return 'Yahoobot'; } if (strpos($useragent, 'baiduspider') !== false){ return 'Baiduspider'; } if (strpos($useragent, 'sohu-search') !== false){ return 'Sohubot'; } if (strpos($useragent, 'lycos') !== false){ return 'Lycos'; } if (strpos($useragent, 'robozilla') !== false){ return 'Robozilla'; } return false; } function nowtime(){ $date=date("Y-m-d.G:i:s"); return $date; } $searchbot = get_naps_bot(); if ($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); 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/octobereva/archive/2007/08/28/1762847.aspx