useragents 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf156f25181e846e227ef98e8be83d5de5e7e52f
4
- data.tar.gz: c856324f156ad7200dfc9d6707241096b7db032d
3
+ metadata.gz: 08ab7dc53384c41466127321a08f8e2cbc860ae6
4
+ data.tar.gz: 57e515b91ba47efb23d3893f6f5c72e1f47b2c14
5
5
  SHA512:
6
- metadata.gz: b51f0ddbce57d90c600858626590dd4f6d3d9aef35a7fa9e3e089caaf61ba6ceb92e1537ebeabc9cc41e2bc0e1d1c0c9e60354e265eb987af810682278481d7d
7
- data.tar.gz: ea8456376609c5310ee8c99e010ce9b953a6b0c0c0c51dbc0ce19cb8d4a20b59cf69c3ceaa1a48bc0dab202d51956cd39b4d48f373343d85794bc6f69992be92
6
+ metadata.gz: 1ac40408c20ea6937fd095b2255b2288dc149f6ba3e4889c2de7bc02fcb6ee06d61e81d785b3e1a3f4055d86183650d320d1a9c352b07bb41489b66130bb5a7f
7
+ data.tar.gz: 3cbb3297d08228fd5dde600b9a282c6bb9eaf099c60191b0689e834056c2f6342de624430bcbd1c2106da6a9c722fe0a3db73f98154358d72709f4e873853bc1
data/lib/fetch.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'useragent'
1
2
  module UserAgents
2
3
  def fetch
3
4
  require 'nokogiri'
@@ -15,7 +16,18 @@ module UserAgents
15
16
  agents = urls.inject([]) do |sum, url|
16
17
  puts "Requesting #{url}"
17
18
  doc = Nokogiri::HTML(open(url))
18
- sum + doc.css('#liste ul li a').map{|link| link.content.strip }
19
+ doc.css('#liste ul li a').each do|link|
20
+ str = link.content.strip
21
+ agent = UserAgent.parse(str)
22
+ case agent.browser
23
+ when "Chrome" ; sum.push(str) if agent.version && agent.version >= '15'
24
+ when "Firefox" ; sum.push(str) if agent.version && agent.version >= '9'
25
+ when "Internet Explorer"; sum.push(str) if agent.version && agent.version >= '7'
26
+ when "Opera" ; sum.push(str) if agent.version && agent.version >= '10'
27
+ when "Safari" ; sum.push(str) if agent.version && agent.version >= '5'
28
+ end
29
+ end
30
+ sum
19
31
  end
20
32
 
21
33
  Zlib::GzipWriter.open(File.expand_path('../useragents.dat', __FILE__)) do |gz|
data/lib/useragents.dat CHANGED
Binary file
data/useragents.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "useragents"
3
- s.version = "0.1.2"
3
+ s.version = "0.1.3"
4
4
 
5
5
  s.authors = "debbbbie"
6
6
  s.date = "2013-12-20"
@@ -11,9 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
  s.summary = "Generate a random User-Agent for you, use for spiders or anything."
13
13
 
14
-
15
- #s.add_dependency "growl"
16
-
17
14
  s.add_development_dependency "rspec"
15
+ #s.add_development_dependency "nokogiri"
16
+ s.add_development_dependency "useragent"
18
17
 
19
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - debbbbie
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: useragent
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Generate a random User-Agent for you
28
42
  email: debbbbie@163.com
29
43
  executables: []