本篇文章是对使用PHP实现蜘蛛访问日志统计的代码进行了详细的分析介绍
需要的朋友参考下
复制代码 代码如下:
$useragent = addslashes(strtolower($_SERVER[HTTP_USER_AGENT]));
if (strpos($useragent googlebot)!== false){$bot = Google;}
elseif (strpos($useragentmediapartnersgoogle) !== false){$bot = Google Adsense;}
elseif (strpos($useragentbaiduspider) !== false){$bot = Baidu;}
elseif (strpos($useragentsogou spider) !== false){$bot = Sogou;}
elseif (strpos($useragentsogou web) !== false){$bot = Sogou web;}
elseif (strpos($useragentsosospider) !== false){$bot = SOSO;}
elseif (strpos($useragentspider) !== false){$bot = Spider;}
elseif (strpos($useragentyahoo) !== false){$bot = Yahoo;}
elseif (strpos($useragentmsn) !== false){$bot = MSN;}
elseif (strpos($useragentmsnbot) !== false){$bot = msnbot;}
elseif (strpos($useragentsohu) !== false){$bot = Sohu;}
elseif (strpos($useragentyodaoBot) !== false){$bot = Yodao;}
elseif (strpos($useragenttwiceler) !== false){$bot = Twiceler;}
elseif (strpos($useragentia_archiver) !== false){$bot = Alexa_;}
elseif (strpos($useragentiaarchiver) !== false){$bot = Alexa;}
elseif (strpos($useragentslurp) !== false){$bot = 雅虎;}
elseif (strpos($useragentbot) !== false){$bot = 其它蜘蛛;}
if(isset($bot)){
$fp = @fopen(bottxta);
fwrite($fpdate(Ymd H:i:s)"t"$_SERVER["REMOTE_ADDR"]"t"$bot"t"http://$_SERVER[SERVER_NAME]$_SERVER["REQUEST_URI"]"rn");
fclose($fp);
}