Created
December 30, 2014 08:49
-
-
Save rmrhz/f56c57a37df4d8d46b4c to your computer and use it in GitHub Desktop.
Simple HTTPAuth based Ruby downloader
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
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