Created
May 11, 2019 22:59
-
-
Save mavisland/c14baca1ef815c7e572b04b69b05d088 to your computer and use it in GitHub Desktop.
Download Images with Ruby
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
#!/usr/bin/ruby | |
urls = [ | |
'http://path.to/image/url', | |
'http://path.to/image/url' | |
] | |
require 'open-uri' | |
def download_image(url, dest) | |
open(url) do |u| | |
File.open(dest, 'wb') { |f| f.write(u.read) } | |
end | |
end | |
urls.each { |url| download_image(url, url.split('/').last) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment