说明:很多人想知道自己的博客网站经常有哪些蜘蛛来过,来过多少次,对于这个问题,通常都会用插件来解决,其实除了插件我们还可以通过使用代码的方法来查看蜘蛛的来访记录,这里就说下方法,本文的代码是从网上找的,然后自己就增加了几个主流的搜索引擎蜘蛛。
方法
首先将下列代码放入主题目录下functions.php
文件。
//统计蜘蛛
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, '360Spider') !== false){
return '360Spider';
}
if (strpos($useragent, 'Sosospider') !== false){
return 'Sosospider';
}
if (strpos($useragent, 'bingbot') !== false){
return 'bingbot';
}
if (strpos($useragent, 'Sogouspider') !== false){
return 'Sogouspider';
}
return false;
}
function nowtime(){
date_default_timezone_set('Asia/Shanghai');
$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="robotslogs.txt";
$time=nowtime();
$data=fopen($file,"a");
$PR="$_SERVER[REQUEST_URI]";
fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage\n page:$PR\r\n");
fclose($data);
}
然后需要在根目录新建一个txt
文本robotslogs.txt
,权限设置为777
,之后访问http://your_domain/robotslogs.txt
就可以很详细的看到蜘蛛的来访记录了。
未经允许不得转载:嘟嘟 » WordPress博客查看搜索引擎蜘蛛来访记录的方法
最新评论
请问下,python3 tg_username_update.py都会提示下面这个是因为什么啊 Traceback (most recent call last): File "tg_username_update.py", line 21, in <module> cake = emojize(":cake:", use_aliases=True) TypeError: emojize() got an unexpected keyword argument 'use_aliases'
不可以了
# Install [Debian] [bullseye] [amd64] Downloading... grep: (standard input): binary file matches Error! grub.cfg. root@RRR2:~#
博主你好,请问cloudfront 上传收费这个是事实吧,已经找了几个贴子确认了。 那有什么好办法能够避开这个收费呢?如果不能避开感觉还是cloudflare 比较稳。
来看看
第5步添加自定义主机名进去后等txt验证提示custom hostname does not name to this zone
那没事了,我静态博客。谢谢
为什么缓存键和源请求那里不设置缓存?