Class: ProxyFetcher::Providers::GatherProxy

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

Overview

GatherProxy provider class.

Instance Method Summary collapse

Methods inherited from Base

#fetch_proxies, fetch_proxies!, #provider_headers, #provider_method, #provider_params

Instance Method Details

#provider_urlObject

Provider URL to fetch proxy list



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

def provider_url
  "https://proxygather.com"
end

#to_proxy(html_node) ⇒ ProxyFetcher::Proxy

Converts HTML node (entry of N tags) to ProxyFetcher::Proxy object.

Parameters:

  • html_node (Object)

    HTML node from the ProxyFetcher::Document DOM model.

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/proxy_fetcher/providers/gather_proxy.rb', line 27

def to_proxy(html_node)
  json = parse_json(html_node)

  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

#xpathObject



14
15
16
# File 'lib/proxy_fetcher/providers/gather_proxy.rb', line 14

def xpath
  '//div[@class="proxy-list"]/table/script'
end