PHP real user vs Search Engine Crawler
While logging visitors keep in mind your site may be visited by Search Engine Crawlers too, to distinguish between Crawler and real user I have below function working for me well, although it may not be perfect or do not have complete list of all search engines be there are the most common and frequent crawlers visits the sites.
here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function is_bot(){ $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz", "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot", "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot", "Butterfly","Twitturls","Me.dium","Twiceler","bot","Bot"); foreach($botlist as $bot) { if(strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) return $bot; } return false; } $which_engine = is_bot(); //if false then it is real user |
Comments
how to use this function?!? where I must place this function in my page?
please help..