2012-09-09 36 views
0

我存儲了每個請求的IP地址,以查看我收到的訪客觀看次數。註冊的IP地址,但不包括機器人

Dim clientIPAddress As String = Request.ServerVariables("REMOTE_ADDR") 
locationsDAL.AddLocationView(locationId, "", User.Identity.Name, clientIPAddress, "website") 

但我注意到,這也存儲爬行我的網站的MSN /谷歌機器人等。

我該如何存儲真正的訪問者的非機器人的IP地址?

回答

0

OK,所以我所做的就是:

Dim clientIPAddress As String = Request.ServerVariables("REMOTE_ADDR") 
If Not CheckIfCrawler(Dns.GetHostEntry(clientIPAddress).HostName) Then 
'log view 
end 

Public Shared Function CheckIfCrawler(ByVal hostname As String) As Boolean 
    If hostname.Contains("googlebot") Then 
     Return True 
    ElseIf hostname.Contains("msnbot") Then 
     Return True 
    ElseIf hostname.Contains("baiduspider") Then 
     Return True 
    ElseIf hostname.Contains("nipple3.mail.ru") Then 
     Return True 
    ElseIf hostname.Contains("reverse.wowrack.com") Then 
     Return True 
    ElseIf hostname.Contains("crawl") Then 
     Return True 
    ElseIf hostname.Contains("spider") Then 
     Return True 
    ElseIf hostname.Contains("nipple2.mail.ru") Then 
     Return True 
    Else 
     Return False 
    End If 
End Function 

這樣我可以使用主機名排除大多數機器人。 每6個月一次,我會再次檢查DB以查看是否有任何特定的主機名有很多的意見。然後我使用IP GeoDB手動檢查,如果該主機名/ IPAddress屬於一個機器人,並且手動添加它到CheckIfCrawler函數。

0

官方模式

http://www.bing.com/community/site_blogs/b/webmaster/archive/2012/08/31/how-to-verify-that-bingbot-is-bingbot.aspx

http://googlewebmastercentral.blogspot.com.es/2006/09/how-to-verify-googlebot.html

此外,您還可以通過用戶代理或範圍IPS檢測機器人。

普通用戶代理:

Googlebot 
    Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) 
Googlebot-Mobile 
    Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)   
bingbot 
    Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) 
MSNBot 
    msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)   
MSRBOT 
    MSRBOT 
+0

謝謝。但這只是一小部分(儘管是最重要的)機器人。有沒有另一種方法可以檢測出它是否是一個bot或用戶代理,我不必檢查特定的用戶代理?謝謝! – Flo

+0

這裏有什麼建議嗎?排除像yandex,yahoo等所有殭屍工具似乎有太多的工作。如果一個殭屍程序抓取我的網站,以便我知道它是一個機器人,那麼是否沒有某種頭部會丟失? – Flo