- 08-03-2012 12:30 PM #1
Quick Tips 2: A Quick Spider/Webcrawler Detector
This is a very rudimentary way to determine if a user is a spider/webcrawler, and deal with them in different ways later in your scripts.
Code:function DetermineIfUserIsSpider() { $_aSpiders = array ( "googlebot","yammybot","openbot","yahoo", "slurp","msnbot","baiduspider", ); foreach ($_aSpiders as $_sSpider) { if (stristr($_SERVER['HTTP_USER_AGENT'],$_sSpider)) { define("USER_IS_SPIDER",true); return; } } define("USER_IS_SPIDER",false); } DetermineIfUserIsSpider();






LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks