PHP统计nginx访问日志中的搜索引擎抓取404链接页面路径
2014-06-30 00:00
1106 查看
我在服务器上有每天切割nginx日志的习惯,所以针对每天各大搜索引擎来访,总能记录一些404页面信息,传统上我只是偶尔分析下日志,但是对于很多日志信息的朋友,人工来筛选可能不是一件容易的事情,这不我个人自己慢慢研究了一点点,针对谷歌、百度、搜搜、360搜索、宜搜、搜狗、必应等搜索引擎的404访问生成为一个txt文本文件,直接上代码test.php。
好就这样了。没有什么高深的技术,只有动手写的过程。
<?php //访问test.php?s=google $domain='http://www.jb51.net'; $spiders=array('baidu'=>'Baiduspider','360'=>'360Spider', 'google'=>'Googlebot','soso'=>'Sosospider','sogou'=> 'Sogou web spider','easou'=>'EasouSpider','bing'=>'bingbot'); $path='/home/nginx/logs/'.date('Y/m/').(date('d')-1).'/access_www.txt'; $s=$_GET['s']; if(!array_key_exists($s,$spiders)) die(); $spider=$spiders[$s]; $file=$s.'_'.date('ym').(date('d')-1).'.txt'; if(!file_exists($file)){ $in=file_get_contents($path); $pattern='/GET (.*) HTTP\/1.1" 404.*'.$spider.'/'; preg_match_all ( $pattern , $in , $matches ); $out=''; foreach($matches[1] as $k=>$v){ $out.=$domain.$v."\r\n"; } file_put_contents($file,$out); } $url=$domain.'/silian/'.$file; echo $url;
好就这样了。没有什么高深的技术,只有动手写的过程。
相关文章推荐
- PHP统计nginx访问日志中的搜索引擎抓取404链接页面路径
- 通过统计nginx访问日志禁止恶意抓取数据的实现
- php统计nginx访问日志的ip访问量
- nginx配置后只有根目录首页index.php能访问,其他页面404
- nginx 日志按天分割并定时匹配404访问链接
- PHP+MYSQL 如何准确实现页面访问统计次数
- shell统计Apache访问日志中指定页面的PV、UV等指标
- PHP抓取网页内容,获取链接绝对路径和图片绝对路径
- shell脚本分析 nginx日志访问次数最多及最耗时的页面(慢查询)
- shell脚本分析 nginx日志访问次数最多及最耗时的页面(慢查询)
- nginx服务器下访问不存在的php页面No input file specified.
- shell脚本分析 nginx日志访问次数最多及最耗时的页面
- centos+nginx+php-fpm+php include fastcgi_params php页面能访问但空白,被fastcgi_params与fastcgi.conf害惨了
- nginx 统计日志访问ip个数
- php教程统计静态html页面浏览访问次数代码
- nginx php页面 error_page 404不起作用解决
- awstats分析nginx日志访问404问题
- 解决nginx服务器访问不存在的php页面显示No input file specified.问题
- PHP抓取网页内容,获取链接绝对路径和图片绝对路径
- nginx 404页面处理以及pathInfo和隐藏index.php总述