Class: ProxyFetcher::Providers::MTPro

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

Overview

MTPro provider class.

Instance Method Summary collapse

Methods inherited from Base

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

Instance Method Details

#load_proxy_list(filters = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/proxy_fetcher/providers/mtpro.rb', line 14

def load_proxy_list(filters = {})
  html = load_html(provider_url, filters)
  JSON.parse(html)
rescue JSON::ParserError
  []
end

#provider_urlObject

Provider URL to fetch proxy list



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

def provider_url
  "https://mtpro.xyz/api/?type=socks"
end

#to_proxy(node) ⇒ ProxyFetcher::Proxy

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

Parameters:

  • node (Object)

    HTML node from the ProxyFetcher::Document DOM model.

Returns:



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

def to_proxy(node)
  ProxyFetcher::Proxy.new.tap do |proxy|
    proxy.addr = node["ip"]
    proxy.port = Integer(node["port"])
    proxy.country = node["country"]
    proxy.anonymity = "Unknown"
    proxy.type = ProxyFetcher::Proxy::SOCKS5
  end
end