很多站长、博主可能最在乎的就是自己的网站的搜录情况,一般情况下我们可以通过查看空间的日志文件来看搜索引擎的爬行记录,不过,很不直观,所以我就改了一下同事给我的一个记录爬行记录的程序,是比较好又比较直观方便操作的!可以获取爬虫的ip,记录下他访问的路径!
效果:
以前的这个程序不能使用,不过我做了一下改动,可以获取爬虫的ip,记录下他访问的路径和时间,并且可以筛选,优化了一下清空表记录!感觉还是很不错,原理是什么呢?就是每个访客访问一个网站的时候都是会带有头信息的,蜘蛛和爬虫其实也是访客,只不过他们会抓取你网页的内容。我们就通过php来获取他的头信息就可以了。程序下载链接:http://l4.yunpan.cn/lk/QkPBdYTxeadZU 效果预览:http://www.521php.com/zhizhu 核心代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<?php include_once 'config.php'; @$ax_ym=$_SERVER['REQUEST_URI']; @$ax_ss=$_SERVER['HTTP_USER_AGENT']; @$ax_url=$_SERVER['HTTP_REFERER']; @$ax_ip=$_SERVER['HTTP_X_FORWARDED_FOR']; if(empty($ax_ip)){ @$ax_ip=$_SERVER['REMOTE_ADDR']; } @$ax_date=date("Y-m-d"); @$ax_time=date("H:i:s"); $baidu=stristr($ax_ss,"Baiduspider"); $google=stristr($ax_ss,"Googlebot"); $soso=stristr($ax_ss,"Sosospider"); $youdao=stristr($ax_ss,"YoudaoBot"); $bing=stristr($ax_ss,"bingbot"); $sogou=stristr($ax_ss,"Sogou web spider"); $yahoo=stristr($ax_ss,"Yahoo! Slurp"); $Alexa=stristr($ax_ss,"Alexa"); $so=stristr($ax_ss,"360Spider"); if($baidu) { $ax_ss="baidu"; } elseif($google) { $ax_ss="Google"; } elseif($soso) { $ax_ss="soso"; } elseif($youdao) { $ax_ss="youdao"; } elseif($bing) { $ax_ss="bing"; } elseif($sogou) { $ax_ss="sogou"; } elseif($yahoo) { $ax_ss="yahoo"; } elseif($Alexa) { $ax_ss="Alexa"; } elseif($so) { $ax_ss="so"; } else { $ax_ss=null; } if($baidu or $google or $soso or $youdao or $bing or $sogou or $yahoo or $Alexa or $so) { $zzsql="insert into robots (robotsname,robotspage,oldurl,robotsip,riqi,shijian) values ('$ax_ss','$ax_ym','$ax_url','$ax_ip','$ax_date','$ax_time')"; $exeok=mysql_query($zzsql,$conn); } ?> |
安装的时候
执行
http://您的域名/zhizhu/install
填写相应的配置信息即可自动完成安装
调用
在需要统计的PHP页面加入如下代码即可
<?php include ‘zhizhu/zz.php’;?>
如果你要想在静态页面调用,可以用<script scr=”/zhizhu/zz.php”></script>也是可以的,js也是可以引入php的
本文链接:http://www.521php.com/archives/996/
程序本天成,妙手偶得之!我们只是代码的搬运工!
转载请注明:http://www.521php.com/archives/996/
2013年01月14日 下午 12:47 Joken | 引用 | #1
师哥,有个问题想要请教,我的域名因为必须备案,但是我推迟了两个月,所以域名还没有真正地解析,只是临时的解析了一个,能够访问,这样的话百度会收录吗?