Zipfile download through CURL to an actual Zip-file in your file structure

一曲冷凌霜 提交于 2019-12-04 11:33:43

You're adding the on_body event after calling perform, which transfers the body. If you move the event declaration to before the perform call, this should work.

I am using ruby 2.0

and my code is:

curl = Curl::Easy.new('http://somepage.cz/index.html')
curl.on_body do |d|
  f = File.open('output_file.html', 'w') {|f| f.write(d)}
end
curl.perform

I had to change File.new to File.open without this it didn't worked. Moving curl.perfom on the end does helped me.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!