4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/analytical/bot_detector.rb', line 4
def analytical_is_robot?(user_agent)
unless user_agent.blank?
user_agent = user_agent.to_s.downcase
whitelist = %w(w3m dillo links elinks lynx)
whitelist.each do |word|
return false if user_agent.index(word) == 0
end
bot_indicators = %w(bot spider search jeeves crawl seek heritrix slurp thumbnails capture ferret webinator scan retriever accelerator upload digg extractor grub scrub)
bot_indicators.each do |word|
return true if user_agent.index word
end
browser_indicators = %w(mozilla browser iphone lynx mobile opera icab)
has_browser_indicator = false
browser_indicators.each do |word|
if user_agent.index word
has_browser_indicator = true
break
end
end
return true if not has_browser_indicator
if user_agent.include? "mozilla"
return true if not user_agent.include? "("
return true if user_agent !~ /mozilla\/\d+/i
end
end
return false
end
|