proxy_fetcher 0.10.1 → 0.10.2

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
  SHA256:
3
- metadata.gz: 90fedddf9296d31071b49be0c44736626987ed973b48395ccfed9b04f0c6ae4a
4
- data.tar.gz: 900464a6378e2d72259e54022df01ec1e50ac95f76f9ec613df803ffd0cf2d78
3
+ metadata.gz: d256aaf841030823ef753d6c2b2726dd7e8e5306dbddae6b6079a26815df4224
4
+ data.tar.gz: a747a8d9ed567ffa6373bd0d30dc9a99e5320cb03b75dd3feb5ef45465144375
5
5
  SHA512:
6
- metadata.gz: bc14dedb91c2a319aa27e3c03b3a881ac0861c378c5b1d8396ca79755f8a80ae86d28e904b999cddafc3f85ad7805ee6386e1fca327ded8a764d60ce572af4a3
7
- data.tar.gz: 4d06f65bd36132ae0fbac2c77b12d34b31e5ec851e68995de86457e0d45f29777bcd06ff8c08c6b3e6830a18278f4984e4ca5c3573b7e564c84da155d60a8946
6
+ metadata.gz: '01997f86deda80383198be18ac9bca8309970fa38ea337a082093822838732038425b642a6806798fa35e2a891b63d679020fad33fd5f447efed00b426b85706'
7
+ data.tar.gz: 2fd10653fdf594e8847d4ebe34cb66c30b3d79d2900bd741768a5d4742ffa50923092f2c8f2bd95e3215f505a073e040e27cad8e2d868ff5837e81078c7d6f95
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ Reverse Chronological Order:
6
6
 
7
7
  * Add your description here
8
8
 
9
+ ## `0.10.2` (2019-03-15)
10
+
11
+ * Remove ProxyDocker provider (no longer workable)
12
+
9
13
  ## `0.10.1` (2019-03-07)
10
14
 
11
15
  * Fix broken ProxyDocker provider.
data/lib/proxy_fetcher.rb CHANGED
@@ -37,7 +37,6 @@ module ProxyFetcher
37
37
  require File.dirname(__FILE__) + '/proxy_fetcher/providers/free_proxy_list_ssl'
38
38
  require File.dirname(__FILE__) + '/proxy_fetcher/providers/gather_proxy'
39
39
  require File.dirname(__FILE__) + '/proxy_fetcher/providers/http_tunnel'
40
- require File.dirname(__FILE__) + '/proxy_fetcher/providers/proxy_docker'
41
40
  require File.dirname(__FILE__) + '/proxy_fetcher/providers/proxy_list'
42
41
  require File.dirname(__FILE__) + '/proxy_fetcher/providers/xroxy'
43
42
  end
@@ -124,11 +124,17 @@ module ProxyFetcher
124
124
  self.providers = self.class.registered_providers
125
125
  end
126
126
 
127
+ def adapter=(value)
128
+ remove_instance_variable(:@adapter_class) if defined?(@adapter_class)
129
+ @adapter = value
130
+ end
131
+
127
132
  def adapter_class
128
133
  return @adapter_class if defined?(@adapter_class)
129
134
 
130
135
  @adapter_class = ProxyFetcher::Document::Adapters.lookup(adapter)
131
136
  @adapter_class.setup!
137
+ @adapter_class
132
138
  end
133
139
 
134
140
  # Setups collection of providers that will be used to fetch proxies.
@@ -14,7 +14,7 @@ module ProxyFetcher
14
14
  end
15
15
 
16
16
  # Add custom provider to common registry.
17
- # Requires proxy provider name ('proxy_docker' for example) and a class
17
+ # Requires proxy provider name ('xroxy' for example) and a class
18
18
  # that implements the parsing logic.
19
19
  #
20
20
  # @param name [String, Symbol]
@@ -53,7 +53,7 @@ module ProxyFetcher
53
53
  def self.setup!(*args)
54
54
  install_requirements!(*args)
55
55
  self
56
- rescue LoadError => error
56
+ rescue LoadError, StandardError => error
57
57
  raise Exceptions::AdapterSetupError.new(name, error.message)
58
58
  end
59
59
  end
@@ -15,7 +15,7 @@ module ProxyFetcher
15
15
  # Minor version number
16
16
  MINOR = 10
17
17
  # Smallest version number
18
- TINY = 1
18
+ TINY = 2
19
19
 
20
20
  # Full version number
21
21
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
@@ -60,7 +60,7 @@ describe ProxyFetcher::Configuration do
60
60
 
61
61
  context 'custom HTML parsing adapter' do
62
62
  it "fails if adapter can't be installed" do
63
- old_config = ProxyFetcher.config.dup
63
+ old_adapter = ProxyFetcher.config.adapter.dup
64
64
 
65
65
  class CustomAdapter < ProxyFetcher::Document::AbstractAdapter
66
66
  def self.install_requirements!
@@ -70,10 +70,10 @@ describe ProxyFetcher::Configuration do
70
70
 
71
71
  ProxyFetcher.config.adapter = CustomAdapter
72
72
 
73
- expect { ProxyFetcher::Manager.new }
73
+ expect { ProxyFetcher.config.adapter_class }
74
74
  .to raise_error(ProxyFetcher::Exceptions::AdapterSetupError)
75
75
 
76
- ProxyFetcher.instance_variable_set('@config', old_config)
76
+ ProxyFetcher.config.adapter = old_adapter
77
77
  end
78
78
  end
79
79
  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.10.1
4
+ version: 0.10.2
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-03-07 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -91,7 +91,6 @@ files:
91
91
  - lib/proxy_fetcher/providers/free_proxy_list_ssl.rb
92
92
  - lib/proxy_fetcher/providers/gather_proxy.rb
93
93
  - lib/proxy_fetcher/providers/http_tunnel.rb
94
- - lib/proxy_fetcher/providers/proxy_docker.rb
95
94
  - lib/proxy_fetcher/providers/proxy_list.rb
96
95
  - lib/proxy_fetcher/providers/xroxy.rb
97
96
  - lib/proxy_fetcher/proxy.rb
@@ -110,7 +109,6 @@ files:
110
109
  - spec/proxy_fetcher/providers/gather_proxy_spec.rb
111
110
  - spec/proxy_fetcher/providers/http_tunnel_spec.rb
112
111
  - spec/proxy_fetcher/providers/multiple_providers_spec.rb
113
- - spec/proxy_fetcher/providers/proxy_docker_spec.rb
114
112
  - spec/proxy_fetcher/providers/proxy_list_spec.rb
115
113
  - spec/proxy_fetcher/providers/xroxy_spec.rb
116
114
  - spec/proxy_fetcher/proxy_spec.rb
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
-
5
- module ProxyFetcher
6
- module Providers
7
- # ProxyDocker provider class.
8
- class ProxyDocker < Base
9
- attr_reader :cookie, :token
10
-
11
- # Provider URL to fetch proxy list
12
- def provider_url
13
- 'https://www.proxydocker.com/en/api/proxylist/'
14
- end
15
-
16
- def provider_method
17
- :post
18
- end
19
-
20
- def provider_params
21
- {
22
- token: @token,
23
- country: 'all',
24
- city: 'all',
25
- state: 'all',
26
- port: 'all',
27
- type: 'all',
28
- anonymity: 'all',
29
- need: 'all',
30
- page: '1'
31
- }
32
- end
33
-
34
- def provider_headers
35
- {
36
- cookie: @cookie
37
- }
38
- end
39
-
40
- # Fetches HTML content by sending HTTP request to the provider URL and
41
- # parses the document (built as abstract <code>ProxyFetcher::Document</code>)
42
- # to return all the proxy entries (HTML nodes).
43
- #
44
- # @return [Array<ProxyFetcher::Document::Node>]
45
- # Collection of extracted HTML nodes with full proxy info
46
- #
47
- # [NOTE] Doesn't support direct filters
48
- def load_proxy_list(*)
49
- load_dependencies
50
-
51
- json = JSON.parse(load_html(provider_url, {}))
52
- json.fetch('proxies', [])
53
- rescue JSON::ParserError
54
- []
55
- end
56
-
57
- # Converts JSON node to <code>ProxyFetcher::Proxy</code>
58
- # object.
59
- #
60
- # @param node [Hash]
61
- # JSON entry from the API response
62
- #
63
- # @return [ProxyFetcher::Proxy]
64
- # Proxy object
65
- #
66
- def to_proxy(node)
67
- ProxyFetcher::Proxy.new.tap do |proxy|
68
- proxy.addr = node['ip']
69
- proxy.port = node['port']
70
-
71
- proxy.type = types_mapping.fetch(node['type'], ProxyFetcher::Proxy::HTTP)
72
- proxy.anonymity = "Lvl#{node['anonymity']}"
73
- proxy.country = node['country']
74
- end
75
- end
76
-
77
- private
78
-
79
- def types_mapping
80
- {
81
- '16' => ProxyFetcher::Proxy::HTTP,
82
- '26' => ProxyFetcher::Proxy::HTTPS,
83
- '3' => ProxyFetcher::Proxy::SOCKS4,
84
- '4' => ProxyFetcher::Proxy::SOCKS5,
85
- '56' => ProxyFetcher::Proxy::HTTP, # CON25
86
- '6' => ProxyFetcher::Proxy::HTTP # CON80
87
- }
88
- end
89
-
90
- def load_dependencies
91
- client = ProxyFetcher.config.http_client.new('https://www.proxydocker.com')
92
- response = client.fetch_with_headers
93
-
94
- @cookie = load_cookie_from(response)
95
- @token = load_token_from(response)
96
- end
97
-
98
- def load_cookie_from(response)
99
- cookie_headers = (response.headers['Set-Cookie'] || [])
100
- cookie_headers.join('; ')
101
- end
102
-
103
- def load_token_from(response)
104
- html = response.body.to_s
105
- html[/meta\s+name\s*=["']_token["']\s+content.+["'](.+?)["']\s*>/i, 1]
106
- end
107
- end
108
-
109
- ProxyFetcher::Configuration.register_provider(:proxy_docker, ProxyDocker)
110
- end
111
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe ProxyFetcher::Providers::ProxyDocker do
6
- before :all do
7
- ProxyFetcher.config.provider = :proxy_docker
8
- end
9
-
10
- it_behaves_like 'a manager'
11
- end