网上有很多教程了,但是好多人不会用,有两种方法
先建立个文件zz.php放根目录,代码如下
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 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="log.txt";$time=nowtime();$data=fopen($file,"a");fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage\n");fclose($data);}?>
1,首页不生成,在index.php
include("zz.php");
2生成html的情况在首页底部模版中加入
<script language="JavaScript" src="/zz.php"></script>
抓到蜘蛛后存放于log.txt
转载请注明:天狐博客 » php统计dede搜索引擎蜘蛛来访情况