Class: ProxyFetcher::Providers::GatherProxy

Inherits:
Base
  • Object
show all
Defined in:
lib/proxy_fetcher/providers/gather_proxy.rb

Constant Summary collapse

PROVIDER_URL =
'http://www.gatherproxy.com/'.freeze

Instance Method Summary collapse

Methods inherited from Base

#fetch_proxies!, fetch_proxies!

Instance Method Details

#load_proxy_listObject



8
9
10
11
# File 'lib/proxy_fetcher/providers/gather_proxy.rb', line 8

def load_proxy_list(*)
  doc = load_document(PROVIDER_URL)
  doc.xpath('//div[@class="proxy-list"]/table/script')
end

#to_proxy(html_element) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/proxy_fetcher/providers/gather_proxy.rb', line 13

def to_proxy(html_element)
  json = parse_json(html_element)

  ProxyFetcher::Proxy.new.tap do |proxy|
    proxy.addr = json['PROXY_IP']
    proxy.port = json['PROXY_PORT'].to_i(16)
    proxy.anonymity = json['PROXY_TYPE']
    proxy.country = json['PROXY_COUNTRY']
    proxy.response_time = json['PROXY_TIME'].to_i
    proxy.type = ProxyFetcher::Proxy::HTTP
  end
end