自用便于统计360蜘蛛的php代码

前段有时间有分享过《将蜘蛛统计为txt展示的php代码》和《自用便于统计百度蜘蛛的php代码》方便用户使用文本文档的方式查看相关搜索引擎蜘蛛来爬取的url链接,方便查询快照是否收录。

今年做360快照秒收的人也比较多,此时准备一个将360spider抓取的url链接保存为txt就显得尤为重要,我们可以将爬取的链接到IIS7下便捷的一键查询是否收录以及收录数量。

操作方法

在服务器根目录新建:spider.php,代码如下:

<?php
function get_naps_bot()
{
	$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($useragent, '360spider') !== false){
	return '360Spider';
}
return false;
}
function nowtime(){
	$date=gmdate("Y-n-j H:i:s",time()+8*3600);
	return $date;
}
$searchbot = get_naps_bot();
if ($searchbot) {
	$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
	$url=$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	$file="spiderlogs.txt";
	$time=nowtime();
	$data=fopen($file,"a");
	fwrite($data,"Time:$time robot:$searchbot URL:$url\n");
	fclose($data);
}
?>

在泛目录的index.php/404.php/sitemapphp的等相关蜘蛛会访问到的文件中插入:

include'spider.php';

查看蜘蛛统计的话,访问:您的域名/spiderlogs.txt

本站所有内容仅限用于学习和研究目的,程序仅供本地断网测试,转载请说明出处!
站群SEO » 自用便于统计360蜘蛛的php代码

发表评论

欢迎 访客 发表评论

聚合全网站群程序及推送工具!

联系站长 联系客服