Created
August 24, 2012 09:51
-
-
Save thisredone/3448443 to your computer and use it in GitHub Desktop.
Retrieves proxies from HideMyAss.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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