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 +4 -4
- data/lib/fetch.rb +13 -1
- data/lib/useragents.dat +0 -0
- data/useragents.gemspec +3 -4
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08ab7dc53384c41466127321a08f8e2cbc860ae6
|
4
|
+
data.tar.gz: 57e515b91ba47efb23d3893f6f5c72e1f47b2c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
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.
|
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: []
|