Using gem Curb (curl) to download file

放肆的年华 提交于 2020-01-03 03:49:07

问题


I have understood that I could use the RubyGem Curb to fulfill my needs of curl'ing down a file to my computer. But I cannot figure out how to actually "touch" the file. This is what I have got so far

include 'rubygems'
include 'curb'

curl = Curl::Easy.new('http://wordpress.org/latest.zip')
curl.perform

I think I understand that perform actually downloads the file. But how can I interact with the file afterwards? Where is it downloaded to?

Regards, Mattias


回答1:


The file can be accessed with the body_str method.

puts curl.body_str



回答2:


Check the docs at http://rdoc.info/gems/curb/0.7.15/.

After perform, the content is in e.g. curl.body_str.



来源:https://stackoverflow.com/questions/5382149/using-gem-curb-curl-to-download-file

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