使用 gem Curb (curl) 下载文件
我知道我可以使用 RubyGem Curb 来满足将文件卷曲到计算机的需求。但我不知道如何实际“触摸”该文件。这是我到目前为止所得到的,
include 'rubygems'
include 'curb'
curl = Curl::Easy.new('http://wordpress.org/latest.zip')
curl.perform
我想我明白 perform
实际上下载了文件。但之后我如何与该文件进行交互呢?下载到哪里了?
问候, 马蒂亚斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以使用 body_str 方法访问该文件。
The file can be accessed with the body_str method.
检查文档 http://rdoc.info/gems/curb/0.7.15/。
执行
后,内容在例如curl.body_str
中。Check the docs at http://rdoc.info/gems/curb/0.7.15/.
After
perform
, the content is in e.g.curl.body_str
.