Ruby将网页中的图片保存到本地

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"

编程技巧