由于程序也要关注seo所以我们必须会查看和记录搜素引擎的爬行记录简单的谢了一下!
/* * agent.php * @author 肖伟 * @description 测试简单的爬虫爬行记录 * @copyright Copyright (c) 2012. yun.widuu.com */ $ServerName = $_SERVER["SERVER_NAME"] ; //主机名 $ServerPort = $_SERVER["SERVER_PORT"] ; //端口 $ScriptName = $_SERVER["SCRIPT_NAME"] ; //当前脚本的路径 $QueryString = $_SERVER["QUERY_STRING"] ; //query string查询字符串 $serverip = $_SERVER["REMOTE_ADDR"] ; //IP地址 $Url="http://".$ServerName ; If ($ServerPort != "80") {$Url = $Url.":".$ServerPort ; } //端口如果不是80端口的组合 $Url=$Url.$ScriptName ; //访问的路径 If ($QueryString !="") {$Url=$Url."?".$QueryString ; } //组合路径 $GetLocationURL=$Url ; $agent1 = $_SERVER["HTTP_USER_AGENT"] ; $agent=strtolower($agent1); $Bot =""; if (strpos($agent,"bot")>-1) {$Bot = "其它蜘蛛";} if (strpos($agent,"googlebot")>-1) {$Bot = "Google";} if (strpos($agent,"mediapartners-google")>-1) {$Bot = "Google Adsense";} if (strpos($agent,"baiduspider")>-1) {$Bot = "Baidu";} if (strpos($agent,"sogou spider")>-1) {$Bot = "Sogou";} if (strpos($agent,"yahoo")>-1) {$Bot = "Yahoo!";} if (strpos($agent,"msn")>-1) {$Bot = "MSN";} if (strpos($agent,"ia_archiver")>-1) {$Bot = "Alexa";} if (strpos($agent,"iaarchiver")>-1) {$Bot = "Alexa";} if (strpos($agent,"sohu")>-1) {$Bot = "Sohu";} if (strpos($agent,"sqworm")>-1) {$Bot = "AOL";} if (strpos($agent,"yodaoBot")>-1) {$Bot = "Yodao";} if (strpos($agent,"iaskspider")>-1) {$Bot = "Iask";} $shijian=date("Y-m-d h:i:s", time()); $str=file_get_contents("wdphp.htm")."爬虫类型:".$Bot."访问IP:".$serverip."访问时间:".$shijian."访问地址:".$GetLocationURL."<br>"; $zhizhu=file_put_contents("wdphp.htm",$str);wdphp.htm
发表评论 取消回复