PHP写的获取各搜索蜘蛛爬行记录代码

yipeiwu_com5年前PHP代码库
那么下面分享一款用php写的获取各搜索蜘蛛爬行记录代码
支持搜索引擎如下
可以记录Baidu,Google,Bing,Yahoo,Soso,Sogou,Yodao爬行网站的记录!
php代码如下
复制代码 代码如下:

<?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);
}
////www.jb51.net收集整理
?>

相关文章

PHP预定义超全局数组变量小结

本文实例讲述了PHP预定义超全局数组变量。分享给大家供大家参考,具体如下: 1.PHP 预定义的超全局变量数组 特性: a.特殊的数组,操作方式没有区别 b.不用声明,php脚本中默认存...

PHP程序中的文件锁、互斥锁、读写锁使用技巧解析

文件锁 全名叫 advisory file lock, 书中有提及。 这类锁比较常见,例如 mysql, php-fpm 启动之后都会有一个pid文件记录了进程id,这个文件就是文件锁。...

Uncaught exception com_exception with message Failed to create COM object

Uncaught exception com_exception with message Failed to create COM object

在PHP中调用IE使用如下代码: 复制代码 代码如下: browser = new COM("InternetExplorer.Application"); 无法正常调用,直接报错:...

php从完整文件路径中分离文件目录和文件名的方法

本文实例讲述了php从完整文件路径中分离文件目录和文件名的方法。分享给大家供大家参考。具体分析如下: basename()函数用于从路径中获得文件名 dirname()函数用于从路径中...

php MsSql server时遇到的中文编码问题

但导到sqlserver 2005后,发现其中文编码只支持GB 和 UCS-2(unicode 16),所以直接在数据库中查询显示正确,但使用php的utf9编码显示时则全是乱码。找了大...