php判断当前访问者是否是爬虫的方法,方法如下:
//判断获取数据的是不是爬虫|机器人 function is_spider() { $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; if (preg_match('#(spider|mj12bot|dotbot|bingbot|googlebot|slurp|SemrushBot|AhrefsBot)#i', $ua)){ return true; } return false; }