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

yipeiwu_com6年前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获取url参数方法总结

本文实例讲述了php获取url参数方法。分享给大家供大家参考。具体如下: 在php中获取url中参数的方法有很多种,其中最简单的就直接使用parse_url函数了,他可以很方便快速的自动...

php使用function_exists判断函数可用的方法

本文实例讲述了php使用function_exists判断函数可用的方法。分享给大家供大家参考。具体如下: 本文所述的函数用来建立一张 gif 格式图形,参数 im 为使用 imagec...

PHP加密函数 Javascript/Js 解密函数

以下函数代码中“123456” 是个加密的key,自己可以随便改。php加密,js解密,貌似没什么意义,主要是key在js中会被看到。不过在某些地方可能会用到。 PHP加密函数 复制代码...

详解在PHP的Yii框架中使用行为Behaviors的方法

一个绑定了行为的类,表现起来是这样的: // Step 1: 定义一个将绑定行为的类 class MyClass extends yii\base\Component { //...

PHP 命令行参数详解及应用

复制代码 代码如下:# 不带参数的执行格式 php安装目录/bin/php scriptname.php # 带参数的执行格式 php安装目录/bin/php scriptname.ph...