proxy_fetcher 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: '0529f88d50000f7c2d3fad641372f5dcddfd40b3'
4
- data.tar.gz: eab7966ac9aacf6cb62a8673280beed0fbb34330
3
+ metadata.gz: 40029164cd3a21183e8f22191e2cd8c01ba05ae3
4
+ data.tar.gz: ff557370ec0e68c0817fb009f9e483f936eaecd4
5
5
  SHA512:
6
- metadata.gz: 45964603f17dc94e09075a1fb2264bc35a56a0667bcbc03a2142156414a23f35ee2d98aad1326fd64c80be7db8a31f5103244852253b56f50c168bb33fac94c1
7
- data.tar.gz: 88ef9ef4e52e31277d0881f0b14b8ebf3095af18b993bee6cf1f0941edd56251a5ee3ea71f7b8ce2f725a127c8c6ef6f9d2c1b5c290103d43879b621cdd1813b
6
+ metadata.gz: 9a1461d4c42c3478675a4ad20e0d5e41a674d3486fe1026fdf4d95a1e484c4048f8f01476aaac14ccfa0c2a9e4e78ad2049e6b284828eeeb7c6670b1d0923630
7
+ data.tar.gz: 98f74fc50f15dc7f21f0f308494e4e874ad184cad512b401173da7ecc648c4fd0672aca45f2f3a4f0ec55aa6c01850d7979b579b8609a013d11c37a59443c10b
data/README.md CHANGED
@@ -57,17 +57,20 @@ gem install proxy_fetcher -v '0.4'
57
57
 
58
58
  ### In Ruby application
59
59
 
60
- Get current proxy list without validation:
60
+ By default ProxyFetcher uses all the available proxy providers. To get current proxy list without validation you
61
+ need to initialize an instance of `ProxyFetcher::Manager` class. During this process ProxyFetcher will automatically load
62
+ and parse all the proxies:
61
63
 
62
64
  ```ruby
63
65
  manager = ProxyFetcher::Manager.new # will immediately load proxy list from the server
64
66
  manager.proxies
65
67
 
66
- #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
68
+ #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
67
69
  # @response_time=5217, @type="HTTP", @anonymity="High">, ... ]
68
70
  ```
69
71
 
70
- You can initialize proxy manager without immediate load of proxy list from the remote server by passing `refresh: false` on initialization:
72
+ You can initialize proxy manager without immediate load of the proxy list from the remote server by passing
73
+ `refresh: false` on initialization:
71
74
 
72
75
  ```ruby
73
76
  manager = ProxyFetcher::Manager.new(refresh: false) # just initialize class instance
@@ -76,18 +79,27 @@ manager.proxies
76
79
  #=> []
77
80
  ```
78
81
 
79
- If you want to clean current proxy list from the dead servers that does not respond to the requests, than you can just call `cleanup!` method:
82
+ `ProxyFetcher::Manager` class is very helpful when you need to manipulate and manager proxies. To get the proxy
83
+ from the list yoy can call `.get` or `.pop` method that will return first proxy and move it to the end of the list.
84
+ This methods has some equivalents like `get!` or aliased `pop!` that will return first **connectable** proxy and
85
+ move it to the end of the list. They both marked as danger methods because all dead proxies will be removed from the list.
86
+
87
+ If you need just some random proxy then call `manager.random_proxy` or it's alias `manager.random`.
88
+
89
+ To clean current proxy list from the dead entries that does not respond to the requests you you need to use `cleanup!`
90
+ or `validate!` method:
80
91
 
81
92
  ```ruby
82
93
  manager.cleanup! # or manager.validate!
83
94
  ```
84
95
 
85
- In order to increase the speed of this operation proxy list validation is performed using Ruby threads.
86
- By default, gem creates a pool with 10 threads, but you can increase this number by passing threads pool
87
- size to the `#cleanup!` (or `#validate!`) method: `manager.validate!(50)`. In that case ProxyFetcher will
88
- process all the fetched proxies in group of 50 threads.
96
+ This action will enumerate proxy list and remove all the entries that doesn't respond by timeout or returns errors.
97
+
98
+ In order to increase the performance proxy list validation is performed using Ruby threads. By default gem creates a
99
+ pool with 10 threads, but you can increase this number by changing `pool_size` configuration option: `ProxyFetcher.config.pool_size = 50`.
100
+ Read more in [Proxy validation speed](#proxy-validation-speed) section.
89
101
 
90
- Get raw proxy URLs as Strings:
102
+ If you need raw proxy URLs (like `host:port`) then you can use `raw_proxies` methods that will return array of strings:
91
103
 
92
104
  ```ruby
93
105
  manager = ProxyFetcher::Manager.new
@@ -97,22 +109,16 @@ manager.raw_proxies
97
109
  # "91.217.42.2:8080", "97.77.104.22:80", "165.234.102.177:8080", ...]
98
110
  ```
99
111
 
100
- If `ProxyFetcher::Manager` was already initialized somewhere, you can refresh the proxy list by calling `#refresh_list!` method:
112
+ You don't need to initialize a new manager every time you want to load actual proxy list from the providers. All you
113
+ need is to refresh the proxy list by calling `#refresh_list!` (or `#fetch!`) method for your `ProxyFetcher::Manager` instance:
101
114
 
102
115
  ```ruby
103
116
  manager.refresh_list! # or manager.fetch!
104
117
 
105
- #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
118
+ #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
106
119
  # @response_time=5217, @type="HTTP", @anonymity="High">, ... ]
107
120
  ```
108
121
 
109
- You can use two methods to get the first proxy from the list:
110
-
111
- * `get` or aliased `pop` (will return first proxy and move it to the end of the list)
112
- * `get!` or aliased `pop!` (will return first **connectable** proxy and move it to the end of the list; all the proxies till the working one will be removed)
113
-
114
- Or you can get just random proxy by calling `manager.random_proxy` or it's alias `manager.random`.
115
-
116
122
  If you need to filter proxy list, for example, by country or response time and selected provider supports filtering with GET params,
117
123
  then you can just pass your filters like a simple Ruby hash to the Manager instance:
118
124
 
@@ -139,7 +145,7 @@ manager = ProxyFetcher::Manager.new(filters: {
139
145
  type: 'All_http'
140
146
  }
141
147
  })
142
-
148
+
143
149
  manager.proxies
144
150
 
145
151
  # => [...]
@@ -149,7 +155,7 @@ You can apply different filters every time you calling `#refresh_list!` (or `#fe
149
155
 
150
156
  ```ruby
151
157
  manager.refresh_list!(country: 'PL', maxtime: '500')
152
-
158
+
153
159
  # => [...]
154
160
  ```
155
161
 
@@ -190,7 +196,7 @@ proxy_fetcher --help
190
196
 
191
197
  ## Configuration
192
198
 
193
- To change open/read timeout for `cleanup!` and `connectable?` methods you need to change ProxyFetcher.config:
199
+ To change open/read timeout for `cleanup!` and `connectable?` methods you need to change `ProxyFetcher.config`:
194
200
 
195
201
  ```ruby
196
202
  ProxyFetcher.configure do |config|
@@ -219,7 +225,7 @@ ProxyFetcher.config.http_client = MyHTTPClient
219
225
  manager = ProxyFetcher::Manager.new
220
226
  manager.proxies
221
227
 
222
- #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
228
+ #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
223
229
  # @response_time=5217, @type="HTTP", @anonymity="High">, ... ]
224
230
  ```
225
231
 
@@ -240,11 +246,11 @@ ProxyFetcher.config.proxy_validator = MyProxyValidator
240
246
  manager = ProxyFetcher::Manager.new
241
247
  manager.proxies
242
248
 
243
- #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
249
+ #=> [#<ProxyFetcher::Proxy:0x00000002879680 @addr="97.77.104.22", @port=3128, @country="USA",
244
250
  # @response_time=5217, @type="HTTP", @anonymity="High">, ... ]
245
-
251
+
246
252
  manager.validate!
247
-
253
+
248
254
  #=> [ ... ]
249
255
  ```
250
256
 
@@ -294,7 +300,7 @@ Also you can call next instance methods for every Proxy object:
294
300
 
295
301
  Currently ProxyFetcher can deal with next proxy providers (services):
296
302
 
297
- * Hide My Name (default one)
303
+ * Hide My Name (**currently does not work**)
298
304
  * Free Proxy List
299
305
  * Free SSL Proxies
300
306
  * Proxy Docker
@@ -30,7 +30,7 @@ module ProxyFetcher
30
30
  @http_client = HTTPClient
31
31
  @proxy_validator = ProxyValidator
32
32
 
33
- self.providers = [:hide_my_name] # currently default one
33
+ self.providers = self.class.registered_providers
34
34
  end
35
35
 
36
36
  def providers=(value)
@@ -9,7 +9,7 @@ module ProxyFetcher
9
9
  # Minor version number
10
10
  MINOR = 4
11
11
  # Smallest version number
12
- TINY = 0
12
+ TINY = 1
13
13
 
14
14
  # Full version number
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
@@ -5,7 +5,7 @@ require 'proxy_fetcher/version'
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'proxy_fetcher'
7
7
  gem.version = ProxyFetcher.gem_version
8
- gem.date = '2017-08-28'
8
+ gem.date = '2017-09-04'
9
9
  gem.summary = 'Ruby gem for dealing with proxy lists from different providers'
10
10
  gem.description = 'This gem can help your Ruby application to make HTTP(S) requests ' \
11
11
  'from proxy server by fetching and validating proxy lists from the different providers.'
@@ -5,5 +5,6 @@ describe ProxyFetcher::Providers::HideMyName do
5
5
  ProxyFetcher.config.provider = :hide_my_name
6
6
  end
7
7
 
8
- it_behaves_like 'a manager'
8
+ # TODO: fix provider
9
+ # it_behaves_like 'a manager'
9
10
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ProxyFetcher::Proxy do
4
4
  before :all do
5
- ProxyFetcher.config.provider = :hide_my_name
5
+ ProxyFetcher.config.provider = :proxy_docker
6
6
  end
7
7
 
8
8
  before do
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.0
4
+ version: 0.4.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: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri