Using gem Curb (curl) to download file

2019-06-03 12:26发布

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

标签: ruby curb
2条回答
Melony?
2楼-- · 2019-06-03 13:09

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

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

查看更多
Lonely孤独者°
3楼-- · 2019-06-03 13:18

The file can be accessed with the body_str method.

puts curl.body_str
查看更多
登录 后发表回答