Using gem Curb (curl) to download file

2019-06-03 12:45发布

问题:

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.



标签: ruby curb