proxy_fetcher 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +3 -1
- data/gemfiles/nokogiri.gemfile +1 -1
- data/gemfiles/oga.gemfile +1 -1
- data/lib/proxy_fetcher.rb +32 -32
- data/lib/proxy_fetcher/client/request.rb +3 -3
- data/lib/proxy_fetcher/configuration.rb +1 -1
- data/lib/proxy_fetcher/document/node.rb +1 -1
- data/lib/proxy_fetcher/utils/http_client.rb +24 -13
- data/lib/proxy_fetcher/version.rb +1 -1
- data/proxy_fetcher.gemspec +2 -2
- data/spec/proxy_fetcher/client/client_spec.rb +5 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071dd5bfeaf01174bf803981de6147f999e75b99a2d03c32e034b72dd5dc7c82
|
4
|
+
data.tar.gz: 1675ce07491e0cbce401c2a113ee7eccdcba0c4cf42ba7e380ad63be988ec91a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42037b0b55109b535e25284815a096154c79bca2f58b107311f5c53da5b9ec0242ab39a6dd9bae48ef3e863c7f43251167180266578ac177887bd3a63215ef1e
|
7
|
+
data.tar.gz: 188dd298f8ea03e5985d89e97f99a12ef5d5384eae03a78f9b77e5172c28ae5990dec64795817d52ea6895395679a6c2f2deafafa3f8617154afb32fc06bc972
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,16 @@ Reverse Chronological Order:
|
|
6
6
|
|
7
7
|
...
|
8
8
|
|
9
|
+
## `0.15.1` (2021-02-17)
|
10
|
+
|
11
|
+
* Support for Ruby 3.0
|
12
|
+
|
13
|
+
## `0.15.0` (2021-01-26)
|
14
|
+
|
15
|
+
* Removed failing providers
|
16
|
+
* Added new
|
17
|
+
* Specs refactoring
|
18
|
+
|
9
19
|
## `0.14.0` (2020-05-11)
|
10
20
|
|
11
21
|
* Add MTPro provider
|
data/Gemfile
CHANGED
@@ -6,9 +6,11 @@ gemspec
|
|
6
6
|
|
7
7
|
gem "nokogiri", "~> 1.8"
|
8
8
|
gem "oga", "~> 3.2"
|
9
|
-
gem "rubocop", "~> 0
|
9
|
+
gem "rubocop", "~> 1.0"
|
10
10
|
|
11
11
|
group :test do
|
12
12
|
gem "coveralls", require: false
|
13
|
+
# Until I find a way to introduce other MITM proxy
|
14
|
+
gem "webrick", "1.4.2"
|
13
15
|
gem "evil-proxy", "~> 0.2"
|
14
16
|
end
|
data/gemfiles/nokogiri.gemfile
CHANGED
data/gemfiles/oga.gemfile
CHANGED
data/lib/proxy_fetcher.rb
CHANGED
@@ -4,47 +4,47 @@ require "uri"
|
|
4
4
|
require "http"
|
5
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__)
|
42
|
-
require File.dirname(__FILE__)
|
43
|
-
require File.dirname(__FILE__)
|
44
|
-
require File.dirname(__FILE__)
|
45
|
-
require File.dirname(__FILE__)
|
46
|
-
require File.dirname(__FILE__)
|
47
|
-
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"
|
48
48
|
end
|
49
49
|
|
50
50
|
@__config_access_lock__ = Mutex.new
|
@@ -41,15 +41,15 @@ module ProxyFetcher
|
|
41
41
|
# @return [String]
|
42
42
|
# response body (requested resource content)
|
43
43
|
#
|
44
|
-
def self.execute(args)
|
45
|
-
new(args).execute
|
44
|
+
def self.execute(**args)
|
45
|
+
new(**args).execute
|
46
46
|
end
|
47
47
|
|
48
48
|
# Initialize new HTTP request
|
49
49
|
#
|
50
50
|
# @return [Request]
|
51
51
|
#
|
52
|
-
def initialize(args)
|
52
|
+
def initialize(**args)
|
53
53
|
raise ArgumentError, "args must be a Hash!" unless args.is_a?(Hash)
|
54
54
|
|
55
55
|
@url = args.fetch(:url)
|
@@ -41,8 +41,8 @@ module ProxyFetcher
|
|
41
41
|
# @return [String]
|
42
42
|
# resource content
|
43
43
|
#
|
44
|
-
def self.fetch(*args)
|
45
|
-
new(*args).fetch
|
44
|
+
def self.fetch(*args, **kwargs, &block)
|
45
|
+
new(*args, **kwargs, &block).fetch
|
46
46
|
end
|
47
47
|
|
48
48
|
# Initialize HTTP client instance
|
@@ -51,15 +51,17 @@ module ProxyFetcher
|
|
51
51
|
#
|
52
52
|
def initialize(url, method: :get, params: {}, headers: {})
|
53
53
|
@url = url.to_s
|
54
|
-
@method = method
|
54
|
+
@method = method.to_sym
|
55
55
|
@params = params
|
56
56
|
@headers = headers
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
unless HTTP::Request::METHODS.include?(@method)
|
59
|
+
raise ArgumentError, "'#{@method}' is a wrong HTTP method name"
|
60
|
+
end
|
60
61
|
|
61
|
-
@
|
62
|
-
@
|
62
|
+
@timeout = ProxyFetcher.config.provider_proxies_load_timeout
|
63
|
+
@http = build_http_engine
|
64
|
+
@ssl_ctx = build_ssl_context
|
63
65
|
end
|
64
66
|
|
65
67
|
# Fetches resource content by sending HTTP request to it.
|
@@ -67,8 +69,10 @@ module ProxyFetcher
|
|
67
69
|
# @return [String]
|
68
70
|
# response body
|
69
71
|
#
|
70
|
-
def fetch
|
71
|
-
response =
|
72
|
+
def fetch(**options)
|
73
|
+
response = perform_http_request
|
74
|
+
return response if options.fetch(:raw, false)
|
75
|
+
|
72
76
|
response.body.to_s
|
73
77
|
rescue StandardError => e
|
74
78
|
ProxyFetcher.config.logger.warn("Failed to process request to #{url} (#{e.message})")
|
@@ -77,13 +81,20 @@ module ProxyFetcher
|
|
77
81
|
|
78
82
|
protected
|
79
83
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
84
|
+
def build_ssl_context
|
85
|
+
OpenSSL::SSL::SSLContext.new.tap do |context|
|
86
|
+
context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
83
87
|
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def build_http_engine
|
91
|
+
HTTP.headers(default_headers.merge(headers)).timeout(connect: timeout, read: timeout)
|
92
|
+
end
|
84
93
|
|
94
|
+
def perform_http_request(http_method: method, http_params: params)
|
85
95
|
http.public_send(
|
86
|
-
http_method
|
96
|
+
http_method,
|
97
|
+
url,
|
87
98
|
form: http_params,
|
88
99
|
ssl_context: ssl_ctx
|
89
100
|
)
|
data/proxy_fetcher.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.version = ProxyFetcher.gem_version
|
10
10
|
gem.summary = "Ruby gem for dealing with proxy lists from different providers"
|
11
11
|
gem.description = <<-TEXT.strip.gsub(/[\s\n]+/, " ")
|
12
|
-
This gem can help your Ruby application to make HTTP(S) requests
|
13
|
-
using proxies by fetching and validating proxy lists from
|
12
|
+
This gem can help your Ruby application to make HTTP(S) requests
|
13
|
+
using proxies by fetching and validating proxy lists from
|
14
14
|
the different providers.
|
15
15
|
TEXT
|
16
16
|
gem.authors = ["Nikita Bulai"]
|
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.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Bulai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -143,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.7.9
|
146
|
+
rubygems_version: 3.1.2
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: Ruby gem for dealing with proxy lists from different providers
|