php获取访问的蜘蛛名字
2022-03-24 PHP 1861
/** * 蜘蛛访问记录 * @return str */ function get_spider() { $user_agent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); $bot_types = [ 'googlebot' => 'Google', 'mediapartners-google' => 'Google Adsense', 'baiduspider' => 'Baidu', 'sogou spider' => 'Sogou', 'sogou web' => 'Sogou web', 'sosospider' => 'SOSO', 'yahoo' => 'Yahoo', 'msn' => 'MSN', 'msnbot' => 'msnbot', 'sohu' => 'Sohu', 'yodaoBot' => 'Yodao', 'twiceler' => 'Twiceler', 'ia_archiver' => 'Alexa_', 'iaarchiver' => 'Alexa', 'slurp' => '雅虎', 'bot' => '其它蜘蛛', ]; $bot = ''; foreach ($bot_types as $key => $value) { if (strpos($user_agent, $key) !== false) { $bot = $value; break; } } return $bot; }
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论