龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

记录各搜索蜘蛛爬行记录php代码

时间:2014-07-22 14:51来源: 作者: 点击:
分享到:
记录各搜索蜘蛛爬行记录php代码,具体代码请看 a href=http://www.tongqiong.com/read.php?tid-109.html rel=nofollowhttp://www.tongqiong.com/read.php?tid-109.html/a
记录各搜索蜘蛛爬行记录php代码,具体代码请看 http://www.tongqiong.com/read.php?tid-109.html
<?php
 //作者:http://www.tongqiong.com
function get_naps_bot()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);

if (strpos($useragent, 'googlebot') !== false){
return 'Google';
}

if (strpos($useragent, 'baiduspider') !== false){
return 'Baidu';
}
if (strpos($useragent, 'msnbot') !== false){
return 'Bing';
}

if (strpos($useragent, 'slurp') !== false){
return 'Yahoo';
}

if (strpos($useragent, 'sosospider') !== false){
return 'Soso';
}

if (strpos($useragent, 'sogou spider') !== false){
return 'Sogou';
}

if (strpos($useragent, 'yodaobot') !== false){
return 'Yodao';
}
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="www.tongqiong.com.txt";
$time=nowtime();
$data=fopen($file,"a");
fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage\n");
fclose($data);
}
//作者:http://www.tongqiong.com
?>
精彩图集

赞助商链接