Over a million developers have joined DZone.

Proxy List Fetcher Using Ruby

·
Proxy list fetcher using Ruby, it saves proxies inside proxy_list.txt file


require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'digest/sha1'

file = File.new("proxy_list.txt", "w")
doc = Hpricot(open("http://www.proxy4free.com/page1.html"))
trs = (doc/"table tr.text")
trs.each do |tr|
  ip = (tr/"td:nth(0)").first.inner_html
  if ip.match(/^[\d\.]+$/)
    port = (tr/"td:nth(1)").first.inner_html
    file.puts "#{ip}:#{port}"
  end
end
file.close
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}