user_agent_randomizer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e53f295bf18f538dd10b977114e4b4c6c7e33277
4
+ data.tar.gz: 0410fa39098c99c586ccf05877b46c387d5b7812
5
+ SHA512:
6
+ metadata.gz: d948ddd3423a0a90e7997dca87933fd6596fd1e20e5f432cb8fe7ac43c547bb7e93b086a8e65b6181e74d26be1ba4e92de8c5d670cc0cf61e4cd7c53ac04c562
7
+ data.tar.gz: a3eedb8c1a78e9316c56d1918e0c726306b62cb92c3e806922d1807e9c763fc8c79e091f3b923a92be71a9d7b9bc22cc2e9775a22e13b4e03b6c7d1bc1781b4a
data/.gitignore ADDED
@@ -0,0 +1,41 @@
1
+ # Mac OS X
2
+ .DS_Store
3
+
4
+ # RubyMine project metadata
5
+ .idea/
6
+
7
+ # Vim/Emacs temporary files
8
+ *.swp
9
+ *.swo
10
+ *~
11
+
12
+ # Unless supporting RVM < 1.11.0 ignore this
13
+ .rvmrc
14
+
15
+ # Ignore RVM environment for gems
16
+ .ruby-version
17
+ .ruby-gemset
18
+
19
+ # Miscellaneous
20
+ *.gem
21
+ *.rbc
22
+ .bundle
23
+ .config
24
+ .yardoc
25
+ Gemfile.lock
26
+ InstalledFiles
27
+ _yardoc
28
+ coverage
29
+ doc/
30
+ lib/bundler/man
31
+ pkg
32
+ rdoc
33
+ spec/reports
34
+ test/tmp
35
+ test/version_tmp
36
+ tmp
37
+ *.bundle
38
+ *.so
39
+ *.o
40
+ *.a
41
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.6
4
+ - 1.8.7
5
+ - 1.9.1
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - 2.1.1
10
+ - 2.1.2
11
+ - jruby-1.6.8
12
+ - jruby-1.7.12
13
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in user_agent_randomizer.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Christoph Pilka
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,63 @@
1
+ # UserAgentRandomizer
2
+
3
+ [![Build Status](https://travis-ci.org/asconix/user_agent_randomizer.png?branch=master)](https://travis-ci.org/asconix/user_agent_randomizer)
4
+
5
+ [![Code Climate](https://codeclimate.com/github/asconix/user_agent_randomizer.png)](https://codeclimate.com/github/asconix/user_agent_randomizer)
6
+
7
+ There exist few use cases where random HTTP User-Agent strings are required. This is the reason why the `user_agent_randomizer` gem exists. Currently the gem provides roundabout 10.700 different User-Agent strings. You can choose a random HTTP User-Agent string from the entire pool as well as fetch a user agent by category.
8
+
9
+ Every HTTP User-Agent string is assigned exactly to one of the following categories:
10
+
11
+ * `crawler`
12
+ * `desktop_browser`
13
+ * `mobile_browser`
14
+ * `console`
15
+ * `offline_browser`
16
+ * `email_client`
17
+ * `link_checker`
18
+ * `email_collector`
19
+ * `validator`
20
+ * `feed_reader`
21
+ * `library`
22
+ * `cloud_platform`
23
+ * `other`
24
+
25
+ ## Installation
26
+
27
+ Add this line to your application's Gemfile:
28
+
29
+ gem 'user_agent_randomizer'
30
+
31
+ And then execute:
32
+
33
+ $ bundle
34
+
35
+ Or install it yourself as:
36
+
37
+ $ gem install user_agent_randomizer
38
+
39
+ ## Usage
40
+
41
+ The usage is simple. You can fetch a random HTTP UserAgent string from the entire pool as well as one from a specified category (see list above):
42
+
43
+ ```ruby
44
+ require 'user_agent_randomizer'
45
+
46
+ # Fetch a random HTTP User-Agent string from the entire pool
47
+ UserAgent.new
48
+ # => "AppEngine-Google; (+http://code.google.com/appengine; appid: longbows-hideout)"
49
+
50
+ # Fetch a random HTTP User-Agent for a desktop browser
51
+ UserAgent.new("desktop_browser")
52
+ # => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Iron/0.2.152.0 Safari/12733120.525"
53
+ ```
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it ( https://github.com/asconix/user_agent_randomizer/fork )
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create a new Pull Request
62
+
63
+ Copyright © 2014 Christoph Pilka, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'zlib'
4
+ require 'bundler/gem_tasks'
5
+
6
+ task :default => [:spec]
7
+ task :spec do
8
+ sh('rspec spec')
9
+ end
10
+
11
+ namespace :user_agents do
12
+ desc "Fetch User-Agent strings from www.useragentstring.com"
13
+ task :fetch do
14
+ urls = [
15
+ {type: "crawler", url: "http://www.useragentstring.com/pages/Crawlerlist/"},
16
+ {type: "desktop_browser", url: "http://www.useragentstring.com/pages/Browserlist/"},
17
+ {type: "mobile_browser", url: "http://www.useragentstring.com/pages/Mobile%20Browserlist/"},
18
+ {type: "console", url: "http://www.useragentstring.com/pages/Consolelist/"},
19
+ {type: "offline_browser", url: "http://www.useragentstring.com/pages/Offline%20Browserlist/"},
20
+ {type: "email_client", url: "http://www.useragentstring.com/pages/E-mail%20Clientlist/"},
21
+ {type: "link_checker", url: "http://www.useragentstring.com/pages/Link%20Checkerlist/"},
22
+ {type: "email_collector", url: "http://www.useragentstring.com/pages/E-mail%20Collectorlist/"},
23
+ {type: "validator", url: "http://www.useragentstring.com/pages/Validatorlist/"},
24
+ {type: "feed_reader", url: "http://www.useragentstring.com/pages/Feed%20Readerlist/"},
25
+ {type: "library", url: "http://www.useragentstring.com/pages/Librarielist/"},
26
+ {type: "cloud_platform", url: "http://www.useragentstring.com/pages/Cloud%20Platformlist/"},
27
+ {type: "other", url: "http://www.useragentstring.com/pages/Otherlist/"}
28
+ ]
29
+ File.open("lib/data/user_agents.yml", 'w') { |file| file.write("---\n") }
30
+ urls.each do |target|
31
+ user_agents = []
32
+ puts "Fetching User-Agent strings for '#{target[:type]}' ..."
33
+ doc = Nokogiri::HTML(open(target[:url]))
34
+ doc.xpath("//div[@id='liste']/ul/li/a").each do |line|
35
+ user_agents << line.content.strip
36
+ end
37
+ File.open("lib/data/user_agents.yml", 'a') do |file|
38
+ file.write("#{target[:type]}:\n")
39
+ user_agents.each do |ua|
40
+ file.write " - '#{ua}'\n"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end