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实现的统计数据功能详解

本文实例讲述了PHP实现的统计数据功能。分享给大家供大家参考,具体如下: 统计,就是把基本的数据,整合起来。 用到sql的,有group by 功能,count功能,order by功能...

php数据库配置文件一般做法分享

config.php文件: 复制代码 代码如下: <?php $db_name="test"; $db_username="root"; global $db_password;...

php 生成随机验证码图片代码

复制代码 代码如下:<?php /** 默认首页 **/ class DefaultController extends AppController { public functi...

PHP下对数组进行排序的函数

经常,开发人员发现在PHP中使用这种数据结构对值或者数组元素进行排序非常有用。PHP提供了一些适合多种数组的排序函数,这些函数允许你在数组内部对元素进行排列,也允许用很多不同的方法对它们...

php中常见的sql攻击正则表达式汇总

本文实例讲述了php中常见的sql攻击正则表达式。分享给大家供大家参考。具体分析如下: 我们都已经知道,在MYSQL 5+中 information_schema库中存储了所有的 库名,...