require 'net/http' require 'fileutils' require "open-uri" response_html = Net::HTTP.get('url', '/', 3000) response_html.scan(/<img.*?src=['"](.*?)['"].*?>/).each do |img| if img[0]=='' next end img[0].scan(/[\/](.*)[\/](.*)/) FileUtils.mkdir_p($1) begin imguri = "url"+img[0].strip data=open(imguri){|f|f.read} open($1+'/'+$2,"wb"){|f|f.write(data)} rescue puts imguri #break end end