proxy_fetcher 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/proxy_fetcher.rb +8 -2
- data/lib/proxy_fetcher/configuration.rb +9 -5
- data/lib/proxy_fetcher/providers/xroxy.rb +8 -8
- data/lib/proxy_fetcher/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57af14d443aa759d7a82f20f68f073d1cf7f864204b9ee70233c8dfad83903c
|
4
|
+
data.tar.gz: 69fcafad4c583fae0d192cf40d0687377158af6145ad3444e8e74d10e7c98bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9023c9bc9b6634e9d8b0e58af0a86c918deff988afbac0fd7872cdc6c85a5fca6b41d92b179687241f2af54d1b0bfbf3e9bd8c97610c7fe3db837b4b91504c66
|
7
|
+
data.tar.gz: 5da728c2e6d57d458df3aa93ef689c4ab1e892e183a2dc780026643cfcc82e017ecf626dc635d5fdd65b95204be784b83d620c188dba9129c30345d3939a28f6
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ Reverse Chronological Order:
|
|
6
6
|
|
7
7
|
* Add your description here
|
8
8
|
|
9
|
+
## `0.12.0` (2020-01-28)
|
10
|
+
|
11
|
+
* Fix XRoxy provider
|
12
|
+
* Fix multi-threading issues with config and adapter
|
13
|
+
|
14
|
+
## `0.11.0` (2019-10-24)
|
15
|
+
|
16
|
+
* Big gem refactoring
|
17
|
+
|
9
18
|
## `0.10.2` (2019-03-15)
|
10
19
|
|
11
20
|
* Remove ProxyDocker provider (no longer workable)
|
data/lib/proxy_fetcher.rb
CHANGED
@@ -41,8 +41,12 @@ module ProxyFetcher
|
|
41
41
|
require File.dirname(__FILE__) + "/proxy_fetcher/providers/xroxy"
|
42
42
|
end
|
43
43
|
|
44
|
+
@__config_access_lock__ = Mutex.new
|
45
|
+
@__config_definition_lock__ = Mutex.new
|
46
|
+
|
44
47
|
# Main ProxyFetcher module.
|
45
48
|
class << self
|
49
|
+
|
46
50
|
##
|
47
51
|
# Returns ProxyFetcher configuration.
|
48
52
|
#
|
@@ -58,7 +62,9 @@ module ProxyFetcher
|
|
58
62
|
# @providers=[:free_proxy_list, ...], @adapter=ProxyFetcher::Document::NokogiriAdapter>
|
59
63
|
#
|
60
64
|
def config
|
61
|
-
@
|
65
|
+
@__config_definition_lock__.synchronize do
|
66
|
+
@config ||= ProxyFetcher::Configuration.new
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
##
|
@@ -70,7 +76,7 @@ module ProxyFetcher
|
|
70
76
|
# Configuration object.
|
71
77
|
#
|
72
78
|
def configure
|
73
|
-
yield config
|
79
|
+
@__config_access_lock__.synchronize { yield config }
|
74
80
|
end
|
75
81
|
|
76
82
|
# Returns ProxyFetcher logger instance.
|
@@ -39,7 +39,7 @@ module ProxyFetcher
|
|
39
39
|
attr_accessor :logger
|
40
40
|
|
41
41
|
# @!attribute [r] adapter
|
42
|
-
# @return [
|
42
|
+
# @return [#to_s] HTML parser adapter
|
43
43
|
attr_reader :adapter
|
44
44
|
|
45
45
|
# @!attribute [r] http_client
|
@@ -68,6 +68,8 @@ module ProxyFetcher
|
|
68
68
|
#
|
69
69
|
DEFAULT_ADAPTER = :nokogiri
|
70
70
|
|
71
|
+
@__adapter_lock__ = Mutex.new
|
72
|
+
|
71
73
|
class << self
|
72
74
|
# Registry for handling proxy providers.
|
73
75
|
#
|
@@ -131,11 +133,13 @@ module ProxyFetcher
|
|
131
133
|
end
|
132
134
|
|
133
135
|
def adapter_class
|
134
|
-
|
136
|
+
self.class.instance_variable_get(:@__adapter_lock__).synchronize do
|
137
|
+
return @adapter_class if defined?(@adapter_class)
|
135
138
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
+
@adapter_class = ProxyFetcher::Document::Adapters.lookup(adapter)
|
140
|
+
@adapter_class.setup!
|
141
|
+
@adapter_class
|
142
|
+
end
|
139
143
|
end
|
140
144
|
|
141
145
|
# Setups collection of providers that will be used to fetch proxies.
|
@@ -6,11 +6,11 @@ module ProxyFetcher
|
|
6
6
|
class XRoxy < Base
|
7
7
|
# Provider URL to fetch proxy list
|
8
8
|
def provider_url
|
9
|
-
"https://
|
9
|
+
"https://madison.xroxy.com/proxylist.html"
|
10
10
|
end
|
11
11
|
|
12
12
|
def xpath
|
13
|
-
"//
|
13
|
+
"//tr[@class='row1' or @class='row0']"
|
14
14
|
end
|
15
15
|
|
16
16
|
# Converts HTML node (entry of N tags) to <code>ProxyFetcher::Proxy</code>
|
@@ -24,12 +24,12 @@ module ProxyFetcher
|
|
24
24
|
#
|
25
25
|
def to_proxy(html_node)
|
26
26
|
ProxyFetcher::Proxy.new.tap do |proxy|
|
27
|
-
proxy.addr = html_node.content_at("td[
|
28
|
-
proxy.port = Integer(html_node.content_at("td[
|
29
|
-
proxy.anonymity = html_node.content_at("td[
|
30
|
-
proxy.country = html_node.content_at("td[
|
31
|
-
proxy.response_time = Integer(html_node.content_at("td[
|
32
|
-
proxy.type = html_node.content_at("td[
|
27
|
+
proxy.addr = html_node.content_at("td[2]")
|
28
|
+
proxy.port = Integer(html_node.content_at("td[3]").gsub(/^0+/, ""))
|
29
|
+
proxy.anonymity = html_node.content_at("td[4]")
|
30
|
+
proxy.country = html_node.content_at("td[6]")
|
31
|
+
proxy.response_time = Integer(html_node.content_at("td[7]"))
|
32
|
+
proxy.type = html_node.content_at("td[4]")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxy_fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Bulai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.0.
|
143
|
+
rubygems_version: 3.0.2
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Ruby gem for dealing with proxy lists from different providers
|