2009-01-10 78 views

回答

11

我已經幸福的Ocean's Browsercaps提供的結果。它支持Microsoft的配置文件沒有檢測到的抓取工具。它甚至可以解析出您網​​站上的抓取工具的版本,而不是我真的需要這種詳細程度。

+0

不錯!我會查一下。 – 2009-01-11 00:56:11

6

你可以檢查(正則表達式)針對Request.UserAgent

Peter Bromberg寫了一篇關於在ASP.NET中編寫ASP.NET Request Logger and Crawler Killer的好文章。

這是他在Logger類使用方法:

public static bool IsCrawler(HttpRequest request) 
{ 
    // set next line to "bool isCrawler = false; to use this to deny certain bots 
    bool isCrawler = request.Browser.Crawler; 
    // Microsoft doesn't properly detect several crawlers 
    if (!isCrawler) 
    { 
     // put any additional known crawlers in the Regex below 
     // you can also use this list to deny certain bots instead, if desired: 
     // just set bool isCrawler = false; for first line in method 
     // and only have the ones you want to deny in the following Regex list 
     Regex regEx = new Regex("Slurp|slurp|ask|Ask|Teoma|teoma"); 
     isCrawler = regEx.Match(request.UserAgent).Success; 
    } 
    return isCrawler; 
} 
+6

警告 - 這是*不是*傻瓜!如果安裝特定版本的Ask.com工具欄(至少在IE中),它將修改用戶代理以某種形式包含「詢問」,從而導致誤報。 – 2010-09-06 23:10:42