vadviktor
8/30/2012 - 2:22 PM

Download files with Ruby

Download files with Ruby

require 'net/http'
require 'uri'

url = URI.parse( "http://mi9.com" )
Net::HTTP.start( url.host, url.port ) do |http|
  (83514..83593).to_a.each do |img|
    img_1280 = http.get "/uploads/abstract/4661/vector-room_1280x1024_#{img}.jpg"
    filename = "vr_1280x1024_#{img}.jpg"
    open( filename, "wb" ) do |file|
      puts "downloading #{filename}"
      file.write img_1280.body
    end
  end
end

puts "Done."