define('isrobot', getrobot());if(defined('norobot') && isrobot) { exit(header(http/1.1 403 forbidden));}
上面这段代码,据说是防止机器人访问的,我不理解哪里代表是机人呢
判断机器人的函数是这么写的,这里面有啥玄机吗
function getrobot() { if(!defined('is_robot')) { $kw_spiders = 'bot|crawl|spider|slurp|sohu-search|lycos|robozilla'; $kw_browsers = 'msie|netscape|opera|konqueror|mozilla'; if(preg_match(/($kw_browsers)/, $_server['http_user_agent'])) { define('is_robot', false); } elseif(preg_match(/($kw_spiders)/, $_server['http_user_agent'])) { define('is_robot', true); } else { define('is_robot', false); } } return is_robot;}
回复讨论(解决方案) bot-微软的bing
spider-百度
slurp-雅虎
其他几个不知道,不过这也只能防止正常的抓取,人家伪造了也不一定能防止
bot-微软的bing
spider-百度
slurp-雅虎
其他几个不知道,不过这也只能防止正常的抓取,人家伪造了也不一定能防止
难道就没有一个好办办吗 流氓要抓也没办法,不过一般的搜索引擎都遵循robots协议
流氓要抓也没办法,不过一般的搜索引擎都遵循robots协议
$kw_spiders = 'bot|crawl|spider|slurp|sohu-search|lycos|robozilla';是啥意思呢 bot|crawl|spider|slurp|sohu-search|lycos|robozilla
是正则要匹配的模式
bot,spider...都是蜘蛛的标识,一般的搜索引擎都会写