asp禁止蜘蛛访问代码
function spiderno()
dim agent: agent = lcase(request.servervariables("http_user_agent"))
dim Bot: Bot = ""
if instr(agent, "googlebot") > 0 then Bot = "Google"
if instr(agent, "mediapartners-google") > 0 then Bot = "Google Adsense"
if instr(agent, "baiduspider") > 0 then Bot = "Baidu"
if instr(agent, "sogou spider") > 0 then Bot = "Sogou"
if instr(agent, "yahoo") > 0 then Bot = "Yahoo!"
if instr(agent, "msn") > 0 then Bot = "MSN"
if instr(agent, "ia_archiver") > 0 then Bot = "Alexa"
if instr(agent, "iaarchiver") > 0 then Bot = "Alexa"
if instr(agent, "sohu") > 0 then Bot = "Sohu"
if instr(agent, "sqworm") > 0 then Bot = "AOL"
if instr(agent, "yodaobot") > 0 then Bot = "Yodao"
if instr(agent, "iaskspider") > 0 then Bot = "Iask"
if len(Bot) > 0 then
Response.End()
end if
end function
php禁止蜘蛛访问代码
function spiderno()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($useragent, 'googlebot') !== false){
exit();
}
if (strpos($useragent, 'msnbot') !== false){
exit();
}
if (strpos($useragent, 'slurp') !== false){
exit();
}
if (strpos($useragent, 'baiduspider') !== false){
exit();
}
if (strpos($useragent, 'sohu-search') !== false){
exit();
}
if (strpos($useragent, 'lycos') !== false){
exit();
}
if (strpos($useragent, 'robozilla') !== false){
exit();
}
}