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收集整理
?>

相关文章

浅谈socket同步和异步、阻塞和非阻塞、I/O模型

在进行网络编程时,常常见到同步(Sync)/异步(Async),阻塞(Block)/非阻塞(Unblock)四种调用方式 同步/异步主要针对C端: 同步:c端发出一个功能调用时,在没有...

php数组总结篇(一)

数组 1.数组的下标是整型数值或者是字符串类型。 eg1.索引数组的键是______,关联数组的键是______。 2.字符串作为索引的时候,应加上引号。常量或者变量不用加引号,否则无法...

浅谈php和js中json的编码和解码

php中 1)编码 $jsonStr = json_encode($array) 2)解码 $arr = json_decode($jsonStr) <?php echo...

对于PHP 5.4 你必须要知道的

PHP 5.4来了,这是自5.3后的又一次主版本升级。此次升级改动较为显著,删除了一些过气儿的函数,带来了高达20%的速度提升和更少的内存使用。 新特性与改动此次更新的关键新特性,包括:...

PHP开发的一些注意点总结

Linux系统的使用 现在标配的系统是 Linux + Nginx + PHP + MySQL ,这样的配置越来越多的大公司在用的了说到配置不同的是一个公司的规约,比如说挂载一般分为2个...