DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Khaled has posted 1 posts at DZone. View Full User Profile

Proxy List Fetcher Using Ruby

09.15.2009
| 5909 views |
  • submit to reddit
        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