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

可以记录Baidu,Google,Bing,Yahoo,Soso,Sogou,Yodao爬行网站的记录

代码如下:

01<?php
02 //http://www.tongqiong.com
03function get_naps_bot()
04{
05$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
06 
07if (strpos($useragent, 'googlebot') !== false){
08return 'Google';
09}
10 
11if (strpos($useragent, 'baiduspider') !== false){
12return 'Baidu';
13}
14if (strpos($useragent, 'msnbot') !== false){
15return 'Bing';
16}
17 
18if (strpos($useragent, 'slurp') !== false){
19return 'Yahoo';
20}
21 
22if (strpos($useragent, 'sosospider') !== false){
23return 'Soso';
24}
25 
26if (strpos($useragent, 'sogou spider') !== false){
27return 'Sogou';
28}
29 
30if (strpos($useragent, 'yodaobot') !== false){
31return 'Yodao';
32}
33return false;
34}
35 
36function nowtime(){
37$date=date("Y-m-d.G:i:s");
38return $date;
39}
40 
41$searchbot = get_naps_bot();
42 
43if ($searchbot) {
44$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
45$url=$_SERVER['HTTP_REFERER'];
46$file="www.tongqiong.com.txt";
47$time=nowtime();
48$data=fopen($file,"a");
49fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage\n");
50fclose($data);
51}
52//http://www.tongqiong.com
53?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值