Skip to content

Instantly share code, notes, and snippets.

@bertomartin
Created April 13, 2014 04:41
Show Gist options
  • Save bertomartin/10569494 to your computer and use it in GitHub Desktop.
Save bertomartin/10569494 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mechanize'
require 'open-uri'
a = Mechanize.new
a.redirect_ok = false
retries = 0
a.get("http://www.illegal-art.net/allday/") do |page|
begin
result = page.form_with(:action => "allday.php") do |f|
f.radiobuttons_with(:name => 'group1')[0].check
end.submit
url = result.response["Location"]
puts "Trying #{url}..."
zip = open(url)
File.open('girl-talk.zip', 'w') { |file| file.print(zip.read) }
rescue Errno::ETIMEDOUT, Timeout::Error
retries += 1
puts "Didn't work. Retrying (#{retries})"
retry
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment