This article describes the PHP implementation of crawling Spider Crawler traces of a piece of code, there is a need for friends reference. Using PHP code to analyze the Spider crawler traces in the Web log, the code is as follows:
' Googlebot ', ' Baidu ' = ' baiduspider ', ' yahoo ' + ' yahoo slurp ' , ' Soso ' = ' sosospider ', ' Msn ' = ' msnbot ', ' AltaVista ' = ' scooter ', ' Sogou ' = ' Sogou spider ', ' Yodao ' = ' Yodaobot '); $userAgent = Strtolower ($_server[' http_user_agent '); foreach ($bots as $k = + $v) {if (Strstr ($v, $userAgent)) {return $k; Break }} return false;} By bbs.it-home.org//What kind of spider crawler to save spider traces. According to whether the http_user_agent is empty to collect/catch spider crawler--by Bbs.it-home.org$spi = Isspider (), if ($SPI) {$TLC _thispage = addslashes ($_server[' http_user_agent '); $file = ' robot.txt '; $time = Date (' y-m-d h:i:s ', mktime ()); $handle = fopen ($file, ' A + '); $PR = $_server[' Request_uri '); Fwrite ($handle, "time:{$time}robot:{$spi} agent:{$tlc _thispage} url:{$PR} \n\r "); Fclose ($handle);}? > |