Sha256: 99ff063623976f57f94f348d4151cdb3d81e45483a29749ace9a6ff151223670

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module ProxyFetcher
  module Providers
    # XRoxy provider class.
    class XRoxy < Base
      # Provider URL to fetch proxy list
      def provider_url
        "https://madison.xroxy.com/proxylist.html"
      end

      def xpath
        "//tr[@class='row1' or @class='row0']"
      end

      # Converts HTML node (entry of N tags) to <code>ProxyFetcher::Proxy</code>
      # object.
      #
      # @param html_node [Object]
      #   HTML node from the <code>ProxyFetcher::Document</code> DOM model.
      #
      # @return [ProxyFetcher::Proxy]
      #   Proxy object
      #
      def to_proxy(html_node)
        ProxyFetcher::Proxy.new.tap do |proxy|
          proxy.addr = html_node.content_at("td[2]")
          proxy.port = Integer(html_node.content_at("td[3]").gsub(/^0+/, ""))
          proxy.anonymity = html_node.content_at("td[4]")
          proxy.country = html_node.content_at("td[6]")
          proxy.response_time = Integer(html_node.content_at("td[7]"))
          proxy.type = html_node.content_at("td[4]")
        end
      end
    end

    ProxyFetcher::Configuration.register_provider(:xroxy, XRoxy)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxy_fetcher-0.12.0 lib/proxy_fetcher/providers/xroxy.rb