Getting a page source into a file using ruby

Does anybody know to get the source of a given webpage saved to a
notepad using ruby? I appreciate your help…

Krishna V. wrote:

Does anybody know to get the source of a given webpage saved to a
notepad using ruby? I appreciate your help…

for instance if we have www.google.com and would want to save the source
of that page to a text pad is there any way we can get this done in
ruby?

Here’s code taken from the help file that comes with Ruby O.-Click
installer for windows:

require ‘net/http’

h = Net::HTTP.new(‘www.pragmaticprogrammer.com’, 80)
resp, data = h.get(’/index.html’, nil)
if resp.message == “OK”
puts data
end

you have the html of the page in the data variable