bot_detector 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bot_detector.gemspec +18 -0
- data/lib/bot_detector.rb +59 -0
- data/spec/bot_detector_spec.rb +11 -0
- metadata +65 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Katrina Owen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# BotDetector
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bot_detector'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install bot_detector
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Katrina Owen"]
|
5
|
+
gem.email = ["katrina.owen@gmail.com"]
|
6
|
+
gem.description = %q{Checks user-agents against a list of known bots.}
|
7
|
+
gem.summary = %q{Checks user-agents against a list of known bots.}
|
8
|
+
gem.homepage = ""
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "bot_detector"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = "0.0.1"
|
16
|
+
|
17
|
+
gem.add_development_dependency "rspec"
|
18
|
+
end
|
data/lib/bot_detector.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module BotDetector
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def patterns
|
5
|
+
@patterns ||= Regexp.union(
|
6
|
+
[
|
7
|
+
/ApacheBench/,
|
8
|
+
/bingbot\/.*; \+http:\/\/www\.bing\.com\/bingbot/,
|
9
|
+
/^Googlebot\//,
|
10
|
+
/^W3C_Validator\//,
|
11
|
+
/^Googlebot-Image\//,
|
12
|
+
/^Feedfetcher-Google/,
|
13
|
+
/^Yahoo! Slurp\//,
|
14
|
+
/^msnbot\//,
|
15
|
+
/^Twiceler-/,
|
16
|
+
/^Gigabot\//,
|
17
|
+
/^FAST Crawler\//,
|
18
|
+
/^Exabot\//,
|
19
|
+
/^ia_archiver/,
|
20
|
+
/^MJ12bot/,
|
21
|
+
/^\/Nutch-/,
|
22
|
+
/^Baiduspider\+/,
|
23
|
+
/^LongURL API/,
|
24
|
+
/^PostRank\//,
|
25
|
+
/PycURL\//,
|
26
|
+
/^Scanmine newsspider/,
|
27
|
+
/^Twitterbot\//,
|
28
|
+
/^Voyager\//,
|
29
|
+
/^kame-rt/,
|
30
|
+
/^Superfeedr/,
|
31
|
+
/^BLP_bbot/,
|
32
|
+
/^Java\//,
|
33
|
+
/^Yandex\//,
|
34
|
+
/^Yeti\//,
|
35
|
+
/^EventMachine HttpClient/,
|
36
|
+
/^Apple-PubSub\//,
|
37
|
+
/^Feed2Mobile\//,
|
38
|
+
/^LinkedInBot\//,
|
39
|
+
/^FeedBurner\//,
|
40
|
+
/^DriftStatus.Com/,
|
41
|
+
/^MLBot/,
|
42
|
+
/^Twingly Recon/,
|
43
|
+
/^R6_FeedFetcher/,
|
44
|
+
/^R6_CommentReader/,
|
45
|
+
/^AdsBot-Google-Mobile/,
|
46
|
+
/^LynnBot\//,
|
47
|
+
/^psbot\//,
|
48
|
+
/^facebookexternalhit\//
|
49
|
+
]
|
50
|
+
)
|
51
|
+
@patterns
|
52
|
+
end
|
53
|
+
|
54
|
+
def bot?(user_agent)
|
55
|
+
user_agent =~ patterns
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'bot_detector'
|
2
|
+
|
3
|
+
describe BotDetector do
|
4
|
+
it "detects a bot" do
|
5
|
+
BotDetector.bot?('Superfeedr 1.8.9 <ugly as hell>').should be_true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "doesn't say it's a bot if it's not" do
|
9
|
+
BotDetector.bot?('The Big Mister Smith v7.42 <in ur face>').should be_false
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bot_detector
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Katrina Owen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70269100811880 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70269100811880
|
25
|
+
description: Checks user-agents against a list of known bots.
|
26
|
+
email:
|
27
|
+
- katrina.owen@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- bot_detector.gemspec
|
38
|
+
- lib/bot_detector.rb
|
39
|
+
- spec/bot_detector_spec.rb
|
40
|
+
homepage: ''
|
41
|
+
licenses: []
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.15
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: Checks user-agents against a list of known bots.
|
64
|
+
test_files:
|
65
|
+
- spec/bot_detector_spec.rb
|