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 查找字符串常用函数介绍

一、strstr — 查找字符串的首次出现 string strstr ( string $haystack , mixed $needle [, bool $before_needle...

php使用Jpgraph绘制简单X-Y坐标图的方法

php使用Jpgraph绘制简单X-Y坐标图的方法

本文实例讲述了php使用Jpgraph绘制简单X-Y坐标图的方法。分享给大家供大家参考。具体实现方法如下: <?php include ("src/jpgraph.p...

PHP微信发送推送消息乱码的解决方法

PHP微信发送推送消息乱码的解决方法

先用urlencode是因为中文在数组转json时会被编码为unicode,微信接口无法识别,所以得在json_encode前先来个编码,等转换后再用urldecode转回来,这样传输...

php动态变量定义及使用

本文实例讲述了php动态变量定义及使用方法。分享给大家供大家参考。具体如下: <?php $var_name = "ic"; //定义变量$var_name $$v...

详谈PHP编码转换问题

最近恰好要用到unicode编码的转换,就去查了一下php的库函数,居然没找到一个函数可以对字符串进行Unicode的编码和解码!也罢,找不到的话就自己实现一下了。。。 Unicode和...