Sha256: d6462a457499e177420167548aba000372c7587a089e90610a2afff5d0888289

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require "json"

module ProxyFetcher
  module Providers
    # MTPro provider class.
    class MTPro < Base
      # Provider URL to fetch proxy list
      def provider_url
        "https://mtpro.xyz/api/?type=socks"
      end

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

      # Converts HTML node (entry of N tags) to <code>ProxyFetcher::Proxy</code>
      # object.
      #
      # @param node [Object]
      #   HTML node from the <code>ProxyFetcher::Document</code> DOM model.
      #
      # @return [ProxyFetcher::Proxy]
      #   Proxy object
      #
      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
    end

    ProxyFetcher::Configuration.register_provider(:mtpro, MTPro)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
proxy_fetcher-0.17.0 lib/proxy_fetcher/providers/mtpro.rb
proxy_fetcher-0.16.0 lib/proxy_fetcher/providers/mtpro.rb
proxy_fetcher-0.15.1 lib/proxy_fetcher/providers/mtpro.rb
proxy_fetcher-0.15.0 lib/proxy_fetcher/providers/mtpro.rb