使用Coldfusion检测机器人

时间:2017-09-12 20:35:55

标签: regex coldfusion user-agent

我需要简单地检测访问者是机器人还是真正的浏览器。我有以下代码:

    <cfset REQUEST.UserAgent = LCase( CGI.http_user_agent ) />
    <cfif REFind( "bot\b", REQUEST.UserAgent ) OR 
    Find( "crawler", REQUEST.UserAgent ) OR 
    Find( "spider", REQUEST.UserAgent ) OR
    Find( "slurp", REQUEST.UserAgent ) OR
    Find( "mediapartners-google", REQUEST.UserAgent )> 
        <cfset notarobot = 0>
    <cfelse>
        <cfset notarobot = 1>
    </cfif>

这会检测到常见的机器人,如MJ12bot,bingbot,slurp,googlebot,yandexbot,baiduspider等?提前谢谢。

0 个答案:

没有答案
相关问题