Module: ProxyPool

Defined in:
lib/proxy_pool.rb,
lib/proxy_pool/dealer.rb,
lib/proxy_pool/version.rb

Defined Under Namespace

Classes: Dealer, Error

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.get(&block) ⇒ Hash

Get a proxy from proxy pool

Returns:

  • (Hash)

    Proxy



19
20
21
# File 'lib/proxy_pool.rb', line 19

def get(&block)
  ProxyPool::Dealer.instance.get(&block)
end

.get_by_country(cn) ⇒ Hash

Get proxy by country

Parameters:

  • cn (String)

    Country code

Returns:

  • (Hash)

    Proxy



34
35
36
# File 'lib/proxy_pool.rb', line 34

def get_by_country(cn)
  get { |proxy| proxy['country'].downcase == cn.downcase }
end

.get_high_anonymous_proxyHash

Get high anonymous proxy

Returns:

  • (Hash)

    Proxy



26
27
28
# File 'lib/proxy_pool.rb', line 26

def get_high_anonymous_proxy
  get { |proxy| proxy['anonymity'] == 'high_anonymous' }
end

.get_http_proxyHash

Get http proxy

Returns:

  • (Hash)

    Proxy



41
42
43
# File 'lib/proxy_pool.rb', line 41

def get_http_proxy
  get { |proxy| proxy['type'] == 'http' }
end

.get_https_proxyHash

Get https proxy

Returns:

  • (Hash)

    Proxy



48
49
50
# File 'lib/proxy_pool.rb', line 48

def get_https_proxy
  get { |proxy| proxy['type'] == 'https' }
end

.remove(proxy) ⇒ nil

Remove this proxy from pool

Parameters:

  • proxy (Hash)

    Proxy

Returns:

  • (nil)


56
57
58
# File 'lib/proxy_pool.rb', line 56

def remove(proxy)
  ProxyPool::Dealer.instance.remove(proxy)
end