Skip to content

Instantly share code, notes, and snippets.

@thisredone
Created August 24, 2012 09:51
Show Gist options
  • Save thisredone/3448443 to your computer and use it in GitHub Desktop.
Save thisredone/3448443 to your computer and use it in GitHub Desktop.
Retrieves proxies from HideMyAss.com
# redka => thisredoned@gmail.com
# 24.08.2012
require 'typhoeus'
require 'nokogiri'
def proxies
front = Typhoeus::Request.get(url = "http://www.hidemyass.com/proxy-list/").body
hydra = Typhoeus::Hydra.new
requests = []
Nokogiri::HTML(front).xpath("//div[@class='pagination']/li")[-2].children[-1].values[0][/\d+/].to_i.downto(2) do |i|
r = Typhoeus::Request.new "#{url}#{i}"
requests << r
hydra.queue r
end
hydra.run
proxies = [front, *requests.map{ |x| x.response.body } ].map do |page|
Nokogiri::HTML(page).xpath("//table[@id='listtable']/tr").map do |tr|
styles = tr.css('td style')[0].text.split("\n")[1..-1].map{|x|Hash[*x[1..-2].split(?{)] }.inject(&:merge)
tr.css("td[2] span")[0].children[1..-1].reject do |c|
c.values.each do |value|
styles.each { |c, d| value.sub! c, d }
end.grep(/display.*none/)[0]
end.map(&:text).join << ':' << tr.xpath("td")[2].text.strip
end
end.inject(&:+)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment