我想下载的文件名后面有一个空格。看起来http.get没有正确传递url_path,因为你可以在浏览器中轻松下载该文件。
如果文件名中有空格,您有任何建议如何下载文件吗?
require net/http
url = "http://www.onalllevels.com/2009-12-02TheYangShow_Squidoo_Part 1.flv"
puts url_base = url.split( / )[2]
puts url_path = / +url.split( / )[3..-1].join( / )
Net::HTTP.start(url_base) do |http|
resp = http.get(url_path)
open("test.flv", "wb") do |file|
file.write(resp.body)
end
end
puts "Done."