Skip to content

Instantly share code, notes, and snippets.

@mavisland
Created May 11, 2019 22:59
Show Gist options
  • Save mavisland/c14baca1ef815c7e572b04b69b05d088 to your computer and use it in GitHub Desktop.
Save mavisland/c14baca1ef815c7e572b04b69b05d088 to your computer and use it in GitHub Desktop.
Download Images with Ruby
#!/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