浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

用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"
posted on 2011-01-20 21:42  lexus  阅读(596)  评论(0编辑  收藏  举报