Class: ProxyFetcher::Providers::ProxyList

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

Constant Summary collapse

PROVIDER_URL =
'https://proxy-list.org/english/index.php'.freeze

Instance Method Summary collapse

Methods inherited from Base

#fetch_proxies!, fetch_proxies!

Instance Method Details

#load_proxy_list(filters = {}) ⇒ Object



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

def load_proxy_list(filters = {})
  doc = load_document(PROVIDER_URL, filters)
  doc.css('.table-wrap .table ul')
end

#to_proxy(html_element) ⇒ Object



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

def to_proxy(html_element)
  ProxyFetcher::Proxy.new.tap do |proxy|
    uri = parse_proxy_uri(html_element)
    proxy.addr = uri.host
    proxy.port = uri.port

    proxy.type = parse_element(html_element, 'li[2]')
    proxy.anonymity = parse_element(html_element, 'li[4]')
    proxy.country = clear(html_element.at_xpath("li[5]//span[@class='country']").attr('title'))
  end
end