Skip to content

Instantly share code, notes, and snippets.

@rmrhz
Created December 30, 2014 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmrhz/f56c57a37df4d8d46b4c to your computer and use it in GitHub Desktop.
Save rmrhz/f56c57a37df4d8d46b4c to your computer and use it in GitHub Desktop.
Simple HTTPAuth based Ruby downloader
require 'open-uri'
urls = [
'http://example.com/image.jpg',
'http://example.com/image2.jpg'
]
urls.each do |url|
open(url, :http_basic_authentication => [user, pass]) {|f|
File.open(File.basename(url),"wb") do |file|
file.puts f.read
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment