proxy_fetcher 0.10.2 → 0.15.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 +22 -1
- data/Gemfile +8 -5
- data/Rakefile +7 -3
- data/gemfiles/nokogiri.gemfile +8 -6
- data/gemfiles/oga.gemfile +8 -6
- data/lib/proxy_fetcher.rb +46 -35
- data/lib/proxy_fetcher/client/client.rb +10 -3
- data/lib/proxy_fetcher/client/request.rb +4 -4
- data/lib/proxy_fetcher/configuration.rb +24 -19
- data/lib/proxy_fetcher/document.rb +0 -9
- data/lib/proxy_fetcher/document/adapters.rb +1 -1
- data/lib/proxy_fetcher/document/adapters/abstract_adapter.rb +3 -12
- data/lib/proxy_fetcher/document/adapters/nokogiri_adapter.rb +1 -1
- data/lib/proxy_fetcher/document/adapters/oga_adapter.rb +1 -1
- data/lib/proxy_fetcher/document/node.rb +2 -2
- data/lib/proxy_fetcher/exceptions.rb +6 -6
- data/lib/proxy_fetcher/manager.rb +42 -9
- data/lib/proxy_fetcher/providers/base.rb +43 -22
- data/lib/proxy_fetcher/providers/free_proxy_list.rb +9 -10
- data/lib/proxy_fetcher/providers/free_proxy_list_socks.rb +58 -0
- data/lib/proxy_fetcher/providers/free_proxy_list_ssl.rb +7 -15
- data/lib/proxy_fetcher/providers/free_proxy_list_us.rb +54 -0
- data/lib/proxy_fetcher/providers/http_tunnel.rb +11 -19
- data/lib/proxy_fetcher/providers/mtpro.rb +43 -0
- data/lib/proxy_fetcher/providers/proxy_list.rb +8 -16
- data/lib/proxy_fetcher/providers/proxypedia.rb +48 -0
- data/lib/proxy_fetcher/providers/proxyscrape_http.rb +65 -0
- data/lib/proxy_fetcher/providers/proxyscrape_socks4.rb +65 -0
- data/lib/proxy_fetcher/providers/proxyscrape_socks5.rb +65 -0
- data/lib/proxy_fetcher/providers/xroxy.rb +9 -17
- data/lib/proxy_fetcher/proxy.rb +16 -4
- data/lib/proxy_fetcher/utils/http_client.rb +7 -12
- data/lib/proxy_fetcher/utils/proxy_list_validator.rb +3 -1
- data/lib/proxy_fetcher/utils/proxy_validator.rb +21 -9
- data/lib/proxy_fetcher/version.rb +3 -3
- data/proxy_fetcher.gemspec +21 -16
- data/spec/fixtures/proxies.txt +14 -0
- data/spec/proxy_fetcher/client/client_spec.rb +72 -57
- data/spec/proxy_fetcher/configuration_spec.rb +11 -11
- data/spec/proxy_fetcher/document/adapters_spec.rb +8 -8
- data/spec/proxy_fetcher/document/node_spec.rb +4 -4
- data/spec/proxy_fetcher/manager_spec.rb +18 -0
- data/spec/proxy_fetcher/providers/base_spec.rb +9 -9
- data/spec/proxy_fetcher/providers/multiple_providers_spec.rb +4 -4
- data/spec/proxy_fetcher/providers/proxy_classes_spec.rb +28 -0
- data/spec/proxy_fetcher/proxy_spec.rb +14 -14
- data/spec/proxy_fetcher/version_spec.rb +2 -0
- data/spec/spec_helper.rb +10 -10
- data/spec/support/manager_examples.rb +21 -21
- metadata +27 -17
- data/lib/proxy_fetcher/providers/gather_proxy.rb +0 -58
- data/spec/proxy_fetcher/providers/free_proxy_list_spec.rb +0 -13
- data/spec/proxy_fetcher/providers/free_proxy_list_ssl_spec.rb +0 -11
- data/spec/proxy_fetcher/providers/gather_proxy_spec.rb +0 -11
- data/spec/proxy_fetcher/providers/http_tunnel_spec.rb +0 -11
- data/spec/proxy_fetcher/providers/proxy_list_spec.rb +0 -11
- data/spec/proxy_fetcher/providers/xroxy_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf6591a8ede2c142fca7f433f3edceb407ed884c1dee6a98e3ca33efbae392e2
|
4
|
+
data.tar.gz: 7d7259da718adec21b8d749d04faf594fa926389e570be6c55bbe9ebf3695783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90eed5f390d122ae58f9bd6c7553b7a1ff6bbca8e65c05406593f53b7a00a4ed160120ae62d0ce8289965810aaa3795287769ee9ef12f9404d805694a8ac0cff
|
7
|
+
data.tar.gz: 31a5b4fcd6199dfc75ca3e89c7bddcc82533ca171f86954e50d4ff44716d73f1ad014f921a05e9eb2fd38a83c5e603eec1fbbf9530b4c01153f6780877388501
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,28 @@ Reverse Chronological Order:
|
|
4
4
|
|
5
5
|
## `master`
|
6
6
|
|
7
|
-
|
7
|
+
...
|
8
|
+
|
9
|
+
## `0.14.0` (2020-05-11)
|
10
|
+
|
11
|
+
* Add MTPro provider
|
12
|
+
* Add Proxypedia provider
|
13
|
+
|
14
|
+
## `0.13.0` (2020-03-09)
|
15
|
+
|
16
|
+
* Fix GatherProxy provider
|
17
|
+
* Fix XRoxy provider
|
18
|
+
* Allow ability to load proxies from files
|
19
|
+
* Fix Proxy object comparators
|
20
|
+
|
21
|
+
## `0.12.0` (2020-01-28)
|
22
|
+
|
23
|
+
* Fix XRoxy provider
|
24
|
+
* Fix multi-threading issues with config and adapter
|
25
|
+
|
26
|
+
## `0.11.0` (2019-10-24)
|
27
|
+
|
28
|
+
* Big gem refactoring
|
8
29
|
|
9
30
|
## `0.10.2` (2019-03-15)
|
10
31
|
|
data/Gemfile
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
+
gem "nokogiri", "~> 1.8"
|
8
|
+
gem "oga", "~> 3.2"
|
9
|
+
gem "rubocop", "~> 0.80"
|
7
10
|
|
8
11
|
group :test do
|
9
|
-
gem
|
10
|
-
gem
|
12
|
+
gem "coveralls", require: false
|
13
|
+
gem "evil-proxy", "~> 0.2"
|
11
14
|
end
|
data/Rakefile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
+
t.rspec_opts = '--tag "~unreliable"'
|
8
|
+
end
|
5
9
|
|
6
10
|
task default: :spec
|
data/gemfiles/nokogiri.gemfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
|
-
|
5
|
+
gemspec path: "../"
|
6
|
+
|
7
|
+
gem "nokogiri", "~> 1.8"
|
6
8
|
|
7
9
|
group :test do
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
10
|
+
gem "coveralls", require: false
|
11
|
+
gem "evil-proxy", "~> 0.2"
|
12
|
+
gem "rspec", "~> 3.9"
|
11
13
|
end
|
data/gemfiles/oga.gemfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
|
-
|
5
|
+
gemspec path: "../"
|
6
|
+
|
7
|
+
gem "oga", "~> 3.0"
|
6
8
|
|
7
9
|
group :test do
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
10
|
+
gem "coveralls", require: false
|
11
|
+
gem "evil-proxy", "~> 0.2"
|
12
|
+
gem "rspec", "~> 3.9"
|
11
13
|
end
|
data/lib/proxy_fetcher.rb
CHANGED
@@ -1,46 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "uri"
|
4
|
+
require "http"
|
5
|
+
require "logger"
|
6
6
|
|
7
|
-
require File.dirname(__FILE__) +
|
7
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/version"
|
8
8
|
|
9
|
-
require File.dirname(__FILE__) +
|
10
|
-
require File.dirname(__FILE__) +
|
11
|
-
require File.dirname(__FILE__) +
|
12
|
-
require File.dirname(__FILE__) +
|
13
|
-
require File.dirname(__FILE__) +
|
14
|
-
require File.dirname(__FILE__) +
|
9
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/exceptions"
|
10
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/configuration"
|
11
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/configuration/providers_registry"
|
12
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/proxy"
|
13
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/manager"
|
14
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/null_logger"
|
15
15
|
|
16
|
-
require File.dirname(__FILE__) +
|
17
|
-
require File.dirname(__FILE__) +
|
18
|
-
require File.dirname(__FILE__) +
|
19
|
-
require File.dirname(__FILE__) +
|
20
|
-
require File.dirname(__FILE__) +
|
21
|
-
require File.dirname(__FILE__) +
|
16
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/utils/http_client"
|
17
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/utils/proxy_validator"
|
18
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/utils/proxy_list_validator"
|
19
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/client/client"
|
20
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/client/request"
|
21
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/client/proxies_registry"
|
22
22
|
|
23
|
-
require File.dirname(__FILE__) +
|
24
|
-
require File.dirname(__FILE__) +
|
25
|
-
require File.dirname(__FILE__) +
|
26
|
-
require File.dirname(__FILE__) +
|
27
|
-
require File.dirname(__FILE__) +
|
28
|
-
require File.dirname(__FILE__) +
|
23
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/document"
|
24
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/document/adapters"
|
25
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/document/node"
|
26
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/document/adapters/abstract_adapter"
|
27
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/document/adapters/nokogiri_adapter"
|
28
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/document/adapters/oga_adapter"
|
29
29
|
|
30
30
|
##
|
31
31
|
# Ruby / JRuby lib for managing proxies
|
32
32
|
module ProxyFetcher
|
33
33
|
# ProxyFetcher providers namespace
|
34
34
|
module Providers
|
35
|
-
require File.dirname(__FILE__) +
|
36
|
-
require File.dirname(__FILE__) +
|
37
|
-
require File.dirname(__FILE__) +
|
38
|
-
require File.dirname(__FILE__) +
|
39
|
-
require File.dirname(__FILE__) +
|
40
|
-
require File.dirname(__FILE__) +
|
41
|
-
require File.dirname(__FILE__) +
|
35
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/base"
|
36
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/free_proxy_list"
|
37
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/free_proxy_list_socks"
|
38
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/free_proxy_list_ssl"
|
39
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/free_proxy_list_us"
|
40
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/http_tunnel"
|
41
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/mtpro"
|
42
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/proxy_list"
|
43
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/proxypedia"
|
44
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/proxyscrape_http"
|
45
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/proxyscrape_socks4"
|
46
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/proxyscrape_socks5"
|
47
|
+
require File.dirname(__FILE__) + "/proxy_fetcher/providers/xroxy"
|
42
48
|
end
|
43
49
|
|
50
|
+
@__config_access_lock__ = Mutex.new
|
51
|
+
@__config_definition_lock__ = Mutex.new
|
52
|
+
|
44
53
|
# Main ProxyFetcher module.
|
45
54
|
class << self
|
46
55
|
##
|
@@ -53,12 +62,14 @@ module ProxyFetcher
|
|
53
62
|
# ProxyFetcher.config
|
54
63
|
#
|
55
64
|
# #=> #<ProxyFetcher::Configuration:0x0000000241eec8 @user_agent="Mozilla/5.0, ...", @pool_size=10,
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
65
|
+
# @client_timeout=3, @proxy_validation_timeout=3, @provider_proxies_load_timeout=30,
|
66
|
+
# @http_client=ProxyFetcher::HTTPClient, @proxy_validator=ProxyFetcher::ProxyValidator,
|
67
|
+
# @providers=[:free_proxy_list, ...], @adapter=ProxyFetcher::Document::NokogiriAdapter>
|
59
68
|
#
|
60
69
|
def config
|
61
|
-
@
|
70
|
+
@__config_definition_lock__.synchronize do
|
71
|
+
@config ||= ProxyFetcher::Configuration.new
|
72
|
+
end
|
62
73
|
end
|
63
74
|
|
64
75
|
##
|
@@ -70,12 +81,12 @@ module ProxyFetcher
|
|
70
81
|
# Configuration object.
|
71
82
|
#
|
72
83
|
def configure
|
73
|
-
yield config
|
84
|
+
@__config_access_lock__.synchronize { yield config }
|
74
85
|
end
|
75
86
|
|
76
87
|
# Returns ProxyFetcher logger instance.
|
77
88
|
#
|
78
|
-
# @return [Logger, NullLogger] logger object
|
89
|
+
# @return [Logger, ProxyFetcher::NullLogger] logger object
|
79
90
|
#
|
80
91
|
def logger
|
81
92
|
return @logger if defined?(@logger)
|
@@ -128,7 +128,11 @@ module ProxyFetcher
|
|
128
128
|
#
|
129
129
|
def request_with_payload(method, url, payload, headers, options)
|
130
130
|
with_proxy_for(url, options.fetch(:max_retries, 1000)) do |proxy|
|
131
|
-
opts = options.merge(
|
131
|
+
opts = options.merge(
|
132
|
+
payload: payload,
|
133
|
+
proxy: options.fetch(:proxy, proxy),
|
134
|
+
headers: default_headers.merge(headers)
|
135
|
+
)
|
132
136
|
|
133
137
|
Request.execute(url: url, method: method, **opts)
|
134
138
|
end
|
@@ -138,7 +142,10 @@ module ProxyFetcher
|
|
138
142
|
#
|
139
143
|
def request_without_payload(method, url, headers, options)
|
140
144
|
with_proxy_for(url, options.fetch(:max_retries, 1000)) do |proxy|
|
141
|
-
opts = options.merge(
|
145
|
+
opts = options.merge(
|
146
|
+
proxy: options.fetch(:proxy, proxy),
|
147
|
+
headers: default_headers.merge(headers)
|
148
|
+
)
|
142
149
|
|
143
150
|
Request.execute(url: url, method: method, **opts)
|
144
151
|
end
|
@@ -152,7 +159,7 @@ module ProxyFetcher
|
|
152
159
|
#
|
153
160
|
def default_headers
|
154
161
|
{
|
155
|
-
|
162
|
+
"User-Agent" => ProxyFetcher.config.user_agent
|
156
163
|
}
|
157
164
|
end
|
158
165
|
|
@@ -50,7 +50,7 @@ module ProxyFetcher
|
|
50
50
|
# @return [Request]
|
51
51
|
#
|
52
52
|
def initialize(args)
|
53
|
-
raise ArgumentError,
|
53
|
+
raise ArgumentError, "args must be a Hash!" unless args.is_a?(Hash)
|
54
54
|
|
55
55
|
@url = args.fetch(:url)
|
56
56
|
@method = args.fetch(:method).to_s.downcase
|
@@ -86,9 +86,9 @@ module ProxyFetcher
|
|
86
86
|
#
|
87
87
|
def build_http_client
|
88
88
|
HTTP.via(proxy.addr, proxy.port.to_i)
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
.headers(headers)
|
90
|
+
.timeout(connect: timeout, read: timeout)
|
91
|
+
.follow(max_hops: max_redirects)
|
92
92
|
end
|
93
93
|
|
94
94
|
# Default SSL options that will be used for connecting to resources
|
@@ -6,15 +6,20 @@ module ProxyFetcher
|
|
6
6
|
#
|
7
7
|
class Configuration
|
8
8
|
# @!attribute client_timeout
|
9
|
-
# @return [Integer]
|
9
|
+
# @return [Integer]
|
10
|
+
# HTTP request timeout (connect / open) for [ProxyFetcher::Client]
|
10
11
|
attr_accessor :client_timeout
|
11
12
|
|
12
13
|
# @!attribute provider_proxies_load_timeout
|
13
|
-
# @return [Integer]
|
14
|
+
# @return [Integer]
|
15
|
+
# HTTP request timeout (connect / open) for loading
|
16
|
+
# of proxies list by provider
|
14
17
|
attr_accessor :provider_proxies_load_timeout
|
15
18
|
|
16
19
|
# @!attribute proxy_validation_timeout
|
17
|
-
# @return [Integer]
|
20
|
+
# @return [Integer]
|
21
|
+
# HTTP request timeout (connect / open) for proxy
|
22
|
+
# validation with [ProxyFetcher::ProxyValidator]
|
18
23
|
attr_accessor :proxy_validation_timeout
|
19
24
|
|
20
25
|
# to save compatibility
|
@@ -30,16 +35,12 @@ module ProxyFetcher
|
|
30
35
|
attr_accessor :user_agent
|
31
36
|
|
32
37
|
# @!attribute [r] logger
|
33
|
-
# @return [
|
38
|
+
# @return [Logger] Logger object
|
34
39
|
attr_accessor :logger
|
35
40
|
|
36
41
|
# @!attribute [r] adapter
|
37
|
-
# @return [
|
38
|
-
|
39
|
-
|
40
|
-
# @!attribute [r] adapter_class
|
41
|
-
# @return [Object] HTML adapter class
|
42
|
-
attr_reader :adapter_class
|
42
|
+
# @return [#to_s] HTML parser adapter
|
43
|
+
attr_reader :adapter
|
43
44
|
|
44
45
|
# @!attribute [r] http_client
|
45
46
|
# @return [Object] HTTP client class
|
@@ -50,7 +51,7 @@ module ProxyFetcher
|
|
50
51
|
attr_reader :proxy_validator
|
51
52
|
|
52
53
|
# @!attribute [r] providers
|
53
|
-
# @return [Array<String
|
54
|
+
# @return [Array<String, Symbol>] proxy providers list to be used
|
54
55
|
attr_reader :providers
|
55
56
|
|
56
57
|
# User-Agent string that will be used by the ProxyFetcher HTTP client (to
|
@@ -58,8 +59,8 @@ module ProxyFetcher
|
|
58
59
|
#
|
59
60
|
# Default is Google Chrome 60, but can be changed in <code>ProxyFetcher.config</code>.
|
60
61
|
#
|
61
|
-
DEFAULT_USER_AGENT =
|
62
|
-
|
62
|
+
DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 " \
|
63
|
+
"(KHTML, like Gecko) Chrome/60.0.3112 Safari/537.36"
|
63
64
|
|
64
65
|
# HTML parser adapter name.
|
65
66
|
#
|
@@ -67,6 +68,8 @@ module ProxyFetcher
|
|
67
68
|
#
|
68
69
|
DEFAULT_ADAPTER = :nokogiri
|
69
70
|
|
71
|
+
@__adapter_lock__ = Mutex.new
|
72
|
+
|
70
73
|
class << self
|
71
74
|
# Registry for handling proxy providers.
|
72
75
|
#
|
@@ -92,7 +95,7 @@ module ProxyFetcher
|
|
92
95
|
|
93
96
|
# Returns registered providers names.
|
94
97
|
#
|
95
|
-
# @return [Array<String
|
98
|
+
# @return [Array<String, Symbol>]
|
96
99
|
# registered providers names
|
97
100
|
#
|
98
101
|
def registered_providers
|
@@ -130,16 +133,18 @@ module ProxyFetcher
|
|
130
133
|
end
|
131
134
|
|
132
135
|
def adapter_class
|
133
|
-
|
136
|
+
self.class.instance_variable_get(:@__adapter_lock__).synchronize do
|
137
|
+
return @adapter_class if defined?(@adapter_class)
|
134
138
|
|
135
|
-
|
136
|
-
|
137
|
-
|
139
|
+
@adapter_class = ProxyFetcher::Document::Adapters.lookup(adapter)
|
140
|
+
@adapter_class.setup!
|
141
|
+
@adapter_class
|
142
|
+
end
|
138
143
|
end
|
139
144
|
|
140
145
|
# Setups collection of providers that will be used to fetch proxies.
|
141
146
|
#
|
142
|
-
# @param value [String, Symbol, Array<String
|
147
|
+
# @param value [String, Symbol, Array<String, Symbol>]
|
143
148
|
# provider names
|
144
149
|
#
|
145
150
|
def providers=(value)
|
@@ -36,14 +36,5 @@ module ProxyFetcher
|
|
36
36
|
def xpath(*args)
|
37
37
|
backend.xpath(*args).map { |node| backend.proxy_node.new(node) }
|
38
38
|
end
|
39
|
-
|
40
|
-
# Searches elements by CSS selector.
|
41
|
-
#
|
42
|
-
# @return [Array<ProxyFetcher::Document::Node>]
|
43
|
-
# collection of nodes
|
44
|
-
#
|
45
|
-
def css(*args)
|
46
|
-
backend.css(*args).map { |node| backend.proxy_node.new(node) }
|
47
|
-
end
|
48
39
|
end
|
49
40
|
end
|
@@ -26,15 +26,6 @@ module ProxyFetcher
|
|
26
26
|
document.xpath(selector)
|
27
27
|
end
|
28
28
|
|
29
|
-
# You can override this method in your own adapter class
|
30
|
-
#
|
31
|
-
# @param selector [String]
|
32
|
-
# CSS selector
|
33
|
-
#
|
34
|
-
def css(selector)
|
35
|
-
document.css(selector)
|
36
|
-
end
|
37
|
-
|
38
29
|
# Returns <code>Node</code> class that will handle HTML
|
39
30
|
# nodes for particular adapter.
|
40
31
|
#
|
@@ -42,7 +33,7 @@ module ProxyFetcher
|
|
42
33
|
# node
|
43
34
|
#
|
44
35
|
def proxy_node
|
45
|
-
self.class.const_get(
|
36
|
+
self.class.const_get("Node")
|
46
37
|
end
|
47
38
|
|
48
39
|
# Installs adapter requirements.
|
@@ -53,8 +44,8 @@ module ProxyFetcher
|
|
53
44
|
def self.setup!(*args)
|
54
45
|
install_requirements!(*args)
|
55
46
|
self
|
56
|
-
rescue LoadError, StandardError =>
|
57
|
-
raise Exceptions::AdapterSetupError.new(name,
|
47
|
+
rescue LoadError, StandardError => e
|
48
|
+
raise Exceptions::AdapterSetupError.new(name, e.message)
|
58
49
|
end
|
59
50
|
end
|
60
51
|
end
|