class ProxyFetcher::Providers::HTTPTunnel

HTTPTunnel provider class.

Public Instance Methods

provider_url() click to toggle source

Provider URL to fetch proxy list

# File lib/proxy_fetcher/providers/http_tunnel.rb, line 8
def provider_url
  "http://www.httptunnel.ge/ProxyListForFree.aspx"
end
to_proxy(html_node) click to toggle source

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

@param html_node [Object]

HTML node from the <code>ProxyFetcher::Document</code> DOM model.

@return [ProxyFetcher::Proxy]

Proxy object
# File lib/proxy_fetcher/providers/http_tunnel.rb, line 25
def to_proxy(html_node)
  ProxyFetcher::Proxy.new.tap do |proxy|
    uri = parse_proxy_uri(html_node)
    proxy.addr = uri.host
    proxy.port = uri.port

    proxy.country = parse_country(html_node)
    proxy.anonymity = parse_anonymity(html_node)
    proxy.type = ProxyFetcher::Proxy::HTTP
  end
end
xpath() click to toggle source
# File lib/proxy_fetcher/providers/http_tunnel.rb, line 12
def xpath
  '//table[contains(@id, "GridView")]/tr[(count(td)>2)]'
end

Private Instance Methods

parse_anonymity(html_node) click to toggle source

Parses HTML node to extract proxy anonymity level.

@param html_node [Object]

HTML node from the <code>ProxyFetcher::Document</code> DOM model.

@return [String]

Anonymity level
# File lib/proxy_fetcher/providers/http_tunnel.rb, line 72
def parse_anonymity(html_node)
  transparency = html_node.content_at("td[5]").to_sym

  {
    A: "Anonymous",
    E: "Elite",
    T: "Transparent",
    U: "Unknown"
  }.fetch(transparency, "Unknown")
end
parse_country(html_node) click to toggle source

Parses HTML node to extract proxy country.

@param html_node [Object]

HTML node from the <code>ProxyFetcher::Document</code> DOM model.

@return [String]

Country code
# File lib/proxy_fetcher/providers/http_tunnel.rb, line 60
def parse_country(html_node)
  html_node.find(".//img").attr("title")
end
parse_proxy_uri(html_node) click to toggle source

Parses HTML node to extract URI object with proxy host and port.

@param html_node [Object]

HTML node from the <code>ProxyFetcher::Document</code> DOM model.

@return [URI]

URI object
# File lib/proxy_fetcher/providers/http_tunnel.rb, line 47
def parse_proxy_uri(html_node)
  full_addr = html_node.content_at("td[1]")
  URI.parse("http://#{full_addr}")
end