且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用WWW:机械化将文件下载到磁盘,而无需先将其全部加载到内存中

更新时间:2023-02-14 21:54:49

您真正想要的是Mechanize :: Download

What you really want is the Mechanize::Download

http://mechanize.rubyforge.org/Mechanize/Download.html

您可以使用这种方式:

require 'mechanize'

agent = Mechanize.new
agent.pluggable_parser.default = Mechanize::Download
agent.get('http://example.com/foo').save('a_file_name')