用ruby下载图片 2009-08-04 22:38 from: http://bbs.railschina.com/thread-23-1-1.html
require "open-uri" data=open("http://bbs.railschina.com/images/default/logo.gif"){|f|f.read} open("logo.gif","wb"){|f|f.write(data)}
require "open-uri" for i in 1..10
uri="http://bbs.railschina.com/images/default/logo" +i.to_s +".gif" data=open(uri){|f|f.read} open("logo" + i.to_s + ".gif","wb"){|f|f.write(data)}
end require 'net/http'
Net::HTTP.start("www.google.com.hk") { |http|
resp = http.get("/images/srpr/nav_logo27.png")
open("D:/test.png", "wb") { |file|
file.write(resp.body)
}
}
puts "OK" |
|