LoginSignup
4
2

More than 5 years have passed since last update.

Rubyで指定したURLの画像をローカルに保存

Posted at
def get_image(url)
  open("img/#{File.basename(url)}", 'wb') do |file|
    file.puts(Net::HTTP.get_response(URI.parse(url)).body)
  end
end

保存場所は適当に変更してください。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2