php - Multilingual website - how to detect bots/spiders? -
this question has answer here:
- search engines , browser accept-language 5 answers
my site changes language according language of user's browser. want bring spinders/bots english-language site (like twitter). http_accept_language of spiders/bots? how detect bots/spiders include file translation in english language? i've seen method of making list of spiders / bots find unsatisfactory. have better solutions?
you can this:
function isspider() { $spiders = array("googlebot","webcrawler","slurp","msn", "voilabot", "furlbot", "naverbot", "mmcrawler"); $spider_count = 0; foreach($spiders $val) { if (preg_match("/$val/i", getenv("http_user_agent"))) { $spider_count++; } } if ($spider_count!= "0") { return true; } else { return false; } } if (isspider()) { // set language english }
you can find list of bot names here: spider names
this assumes bot sets user agent, valid assumption search engines crawlers.
Comments
Post a Comment