PHP寫(xiě)的獲取各搜索蜘蛛爬行記錄代碼
網(wǎng)站百度蜘蛛等搜索引擎爬蟲(chóng)是否了網(wǎng)站 來(lái)抓取文章,一般站長(zhǎng)不知道怎么搞用工具查詢(xún),也可以查看空間里的日志,但是空間里的日志的記錄全是代碼你不知道那個(gè)是搜索引擎爬蟲(chóng)的來(lái)路。那么下面分享一款用php寫(xiě)的獲取各搜索蜘蛛爬行記錄代碼。
支持搜索引擎如下
可以記錄Baidu,Google,Bing,Yahoo,Soso,Sogou,Yodao爬行網(wǎng)站的記錄!
php代碼如下
復(fù)制代碼 代碼如下:
<?php
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.jb51.net.txt";
$time=nowtime();
$data=fopen($file,"a");
fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage\n");
fclose($data);
}
/pic/pic/p>
?>
【PHP寫(xiě)的獲取各搜索蜘蛛爬行記錄代碼】相關(guān)文章:
php獲取新浪微博數(shù)據(jù)API的實(shí)例代碼02-18
php下載代碼怎么寫(xiě)12-13
PHP獲取MySQL數(shù)據(jù)庫(kù)里所有表的實(shí)現(xiàn)代碼11-04
如何在cmd下面寫(xiě)php代碼11-04
PHP獲取星期的方法08-08
PHP如何獲取表單10-26
php分頁(yè)類(lèi)代碼08-05