downloading web page as HTML accessed through WATIR

Discussion in 'Ruby' started by michael, Oct 19, 2006.

  1. michael

    michael Guest

    is there anyway to download the page accessed through WATIR as html
    page??

    for instance,


    require 'watir'

    ie = Watir::IE.start("http://www.yahoo.com")


    above codes will open www.yahoo.com.. what should we do to download
    this page as yahoo.htm??

    any suggestion or hints will be deeply appreciated..


    michael
    michael, Oct 19, 2006
    #1
    1. Advertising

  2. michael

    Guest

    ie.html is what you are looking for

    aFile = File.new("yahoo.htm" , "w")
    aFile << ie.html
    aFile.close

    and if you want to view the file then

    ie.goto("yahoo.htm")

    michael wrote:
    > is there anyway to download the page accessed through WATIR as html
    > page??
    >
    > for instance,
    >
    >
    > require 'watir'
    >
    > ie = Watir::IE.start("http://www.yahoo.com")
    >
    >
    > above codes will open www.yahoo.com.. what should we do to download
    > this page as yahoo.htm??
    >
    > any suggestion or hints will be deeply appreciated..
    >
    >
    > michael
    , Oct 22, 2006
    #2
    1. Advertising

  3. --------------enig6BF3527D94378911740CEE77
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable

    michael wrote:
    > is there anyway to download the page accessed through WATIR as html
    > page??
    >=20
    > for instance,
    >=20
    >=20
    > require 'watir'
    >=20
    > ie =3D Watir::IE.start("http://www.yahoo.com")
    >=20
    >=20
    > above codes will open www.yahoo.com.. what should we do to download
    > this page as yahoo.htm??
    >=20
    > any suggestion or hints will be deeply appreciated..
    >=20
    >=20


    If this is all you need, you might as well use Net:HTTP, or open-uri -
    this should have smaller overhead since you're not instantiating an IE
    control.

    require 'open-uri'

    open('http://www.yahoo.com/') { |html|
    open('yahoo.html', 'w') { |out|
    out.print(html.read)
    }
    }

    David Vallner


    --------------enig6BF3527D94378911740CEE77
    Content-Type: application/pgp-signature; name="signature.asc"
    Content-Description: OpenPGP digital signature
    Content-Disposition: attachment; filename="signature.asc"

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.5 (MingW32)

    iD8DBQFFO2+zy6MhrS8astoRAkUKAJ96rYWkLXiM9KUrLflYhKCZLtVGKgCdFtFu
    J1DKU0MjpGzSRGjxX8HSEJ0=
    =5vlt
    -----END PGP SIGNATURE-----

    --------------enig6BF3527D94378911740CEE77--
    David Vallner, Oct 22, 2006
    #3
  4. wrote:
    > ie.html is what you are looking for
    >
    > aFile = File.new("yahoo.htm" , "w")
    > aFile << ie.html
    > aFile.close
    >
    > and if you want to view the file then
    >
    > ie.goto("yahoo.htm")


    Be very very careful here, make sure you understand what you are doing.
    Watir does *not* see the HTML on the page-- Watir only sees the DOM in
    Internet Explorer. If the HTML is missing a "/p>", for instance, Watir
    can't see it. The #html method will *always* yield valid HTML, because
    it it interpreting the DOM, regardless of how awful the original HTML
    may or may not be.
    Chris McMahon, Oct 24, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mohammad Ali via DotNetMonster.com

    "Deleted row information cannot be accessed through the row." WHY!!

    Mohammad Ali via DotNetMonster.com, Apr 16, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,242
    Mohammad Ali via DotNetMonster.com
    Apr 16, 2005
  2. Replies:
    2
    Views:
    1,240
    jacob navia
    Sep 14, 2006
  3. michael

    downloading web pages in watir

    michael, Aug 8, 2006, in forum: Ruby
    Replies:
    3
    Views:
    299
    Chris McMahon
    Aug 9, 2006
  4. curious
    Replies:
    1
    Views:
    103
    curious
    Dec 5, 2006
  5. Anukul Singhal
    Replies:
    1
    Views:
    160
    Charley Baker
    May 15, 2008
Loading...

Share This Page