How do I download a file over HTTP using Ruby?
+3
A:
There are several ways, but the easiest is probably OpenURI. This blog post has some sample code, and also goes over Net::HTTP (with Hpricot) and Rio.
Jordan
2009-12-09 21:58:03
+3
A:
require 'net/http'
#part of base library
Net::HTTP.start("your.webhost.com") { |http|
resp = http.get("/yourfile.xml")
open("yourfile.xml", "wb") { |file|
file.write(resp.body)
}
}
MattMcKnight
2009-12-09 21:59:18