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

相关文章

Yii使用smsto短信接口的函数demo示例

本文实例讲述了Yii使用smsto短信接口的函数。分享给大家供大家参考,具体如下: public function smsto($telphone,$message) { /...

PHP之十六个魔术方法详细介绍

PHP中把以两个下划线__开头的方法称为魔术方法(Magic methods),这些方法在PHP中充当了举足轻重的作用。 魔术方法包括: __construct(),类的构造函数...

php文件操作之文件写入字符串、数组的方法分析

php文件操作之文件写入字符串、数组的方法分析

本文实例讲述了php文件操作之文件写入字符串、数组的方法。分享给大家供大家参考,具体如下: 场景一:用文本文档记录一些操作日志,因为对于一些频繁的操作,操作记录的数据量势必会很大,...

PHP执行linux系统命令的常用函数使用说明

system函数 说明:执行外部程序并显示输出资料。 语法:string system(string command, int [return_var]); 返回值: 字符串 详细介绍:...

不要轻信 PHP_SELF的安全问题

复制代码 代码如下:<html> <body> <?php if (isset($_REQUEST['submitted']) && $_REQUEST['...