Sha256: fca58abaa104e82ad93373e1edc71fee5c70f87d484b32560af2ec19a3794467

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module ProxyFetcher
  module Providers
    class XRoxy < Base
      PROVIDER_URL = 'http://www.xroxy.com/proxylist.php?port=&type=All_http'.freeze

      class << self
        def load_proxy_list
          doc = Nokogiri::HTML(load_html(PROVIDER_URL))
          doc.xpath('//div[@id="content"]/table[1]/tr[contains(@class, "row")]')
        end
      end

      def parse!(html_entry)
        html_entry.xpath('td').each_with_index do |td, index|
          case index
          when 1
            set!(:addr, td.content.strip)
          when 2
            set!(:port, Integer(td.content.strip))
          when 3
            set!(:anonymity,  td.content.strip)
          when 4
            ssl = td.content.strip.downcase
            set!(:type, ssl.include?('true') ? 'HTTPS' : 'HTTP')
          when 5 then
            set!(:country, td.content.strip)
          when 6
            set!(:response_time, Integer(td.content.strip))
          else
            # nothing
          end
        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.2.5 lib/proxy_fetcher/providers/xroxy.rb