Downloading web pages in watir

could anybody tell me how to download web pages accessed through
watir??

thanks

michael

michael wrote:

could anybody tell me how to download web pages accessed through
watir??

thanks

michael

While there isn’t any methods in Watir to directly download a webpage to
a file, you can get the HTML content yourself and do your own file
writing.

for example;

ie = Watir::IE.new
ie.goto(‘www.google.ca’)

File.open(‘google.html’, “wb”) { |f|
f << ‘’
f << ie.html
f << ‘’
}

Note that the Watir.ie.html method returns the document.body, which does
not include the opening and closing tags - so you’ll need to
include them in the file writing block.

thanks…

body is all I want…

okay… let’s suppose i would like to download ‘www.yahoo.com’, and save
it as c:\yahoo\yahoo.htm

would you show me how I can realize this in ruby, watir??

thank you so much…

michael

Note that the Watir.ie.html method returns the document.body, which does
not include the opening and closing tags - so you’ll need to
include them in the file writing block.

Also note that Watir does not return the actual HTML. It returns the
DOM, represented as HTML. As an example, HTML generated from Watir’s
“ie.html:” always has closed

tags, but the page itself might not.
This causes trouble sometimes.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs