2012-09-09 32 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