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.3.0'

Class Method Summary collapse

Class Method Details

.get(&block) ⇒ Hash

Get a proxy from proxy pool

Returns:

  • (Hash)

    Proxy



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

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



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

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

.get_high_anonymous_proxyHash

Get high anonymous proxy

Returns:

  • (Hash)

    Proxy



32
33
34
# File 'lib/proxy_pool.rb', line 32

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

.get_http_proxyHash

Get http proxy

Returns:

  • (Hash)

    Proxy



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

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

.get_https_proxyHash

Get https proxy

Returns:

  • (Hash)

    Proxy



54
55
56
# File 'lib/proxy_pool.rb', line 54

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

.remove(proxy) ⇒ nil

Remove this proxy from pool

Parameters:

  • proxy (Hash)

    Proxy

Returns:

  • (nil)


62
63
64
# File 'lib/proxy_pool.rb', line 62

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

.updateObject

Update proxy pool



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

def update
  ProxyPool::Dealer.instance.update
end