Reputation: 15
I am trying to a save a website to an HTML file using Ruby. When I open the file, the website is empty.
Currently trying:
doc = system("wget -r -l 1 http://google.com")
my_file = 'google.html'
f = File.open(my_file, 'w')
f.write(doc)
f.close
I can get it working using Nokogiri, but I'm trying to keep it as simplistic as possible.
Upvotes: 0
Views: 203
Reputation: 14189
I advise you to use Net::HTTP instead of any external utility to download pages in Ruby.
But if you must, read this article on calling programs from Ruby.
Basically you must call (backtick)wget ...(backtick)
(sorry about the parser) or %x[wget ...]
instead of system
if you're interested in the program's output.
Upvotes: 1