proxy_fetcher 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a0d7b377ed3c25e50552e89ba76c0e73fad3923bf171e1cee2f592d777787c3
4
- data.tar.gz: 83b594e04e03c74a63146a6907c99025d50607c88f8cf94f6d5ce044795243ad
3
+ metadata.gz: d57af14d443aa759d7a82f20f68f073d1cf7f864204b9ee70233c8dfad83903c
4
+ data.tar.gz: 69fcafad4c583fae0d192cf40d0687377158af6145ad3444e8e74d10e7c98bb7
5
5
  SHA512:
6
- metadata.gz: 1f096c2473035255eb9492297b5641ab5caee62566eb20eb40d3b2f02eea5d06fa1279a2cadeb3266c0f52ce98040185a69678faf116b6398c2c75f79d5c4ebd
7
- data.tar.gz: a9372ef8bdbb3c51c5060308cbc46c905df3819e682bceb858ba494f5f94722095f2a2bee94575606f628d091b87325425c218f8c31a2b807bcb159c59ba6e65
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
- @config ||= ProxyFetcher::Configuration.new
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 [Object] HTML parser adapter
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
- return @adapter_class if defined?(@adapter_class)
136
+ self.class.instance_variable_get(:@__adapter_lock__).synchronize do
137
+ return @adapter_class if defined?(@adapter_class)
135
138
 
136
- @adapter_class = ProxyFetcher::Document::Adapters.lookup(adapter)
137
- @adapter_class.setup!
138
- @adapter_class
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://www.xroxy.com/free-proxy-lists/"
9
+ "https://madison.xroxy.com/proxylist.html"
10
10
  end
11
11
 
12
12
  def xpath
13
- "//div/table/tbody/tr"
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[1]")
28
- proxy.port = Integer(html_node.content_at("td[2]").gsub(/^0+/, ""))
29
- proxy.anonymity = html_node.content_at("td[3]")
30
- proxy.country = html_node.content_at("td[5]")
31
- proxy.response_time = Integer(html_node.content_at("td[6]"))
32
- proxy.type = html_node.content_at("td[3]")
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
@@ -13,7 +13,7 @@ module ProxyFetcher
13
13
  # Major version number
14
14
  MAJOR = 0
15
15
  # Minor version number
16
- MINOR = 11
16
+ MINOR = 12
17
17
  # Smallest version number
18
18
  TINY = 0
19
19
 
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.11.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: 2019-10-24 00:00:00.000000000 Z
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.3
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