require 'open-uri' def to_date(date) if date.to_s.length < 2 "0" + date.to_s else date.to_s end end dirname = 'img/' 0.step 23, 1 do |hour| 0.step 59, 1 do |min| hour = to_date(hour) min = to_date(min) open(dirname + hour + min + "jp.jpg", 'wb') do |output| open("http://www.bijint.com/jp/tokei_images/#{hour + min}.jpg", "Referer" => "http://www.bijint.com/jp/") do |img| output.write(img.read) end