WAtir usage

Discussion in 'Ruby' started by junkone@rogers.com, Jul 8, 2006.

  1. Guest

    Hi
    I found Watir and am excited to use it. I cannot find much examples in
    terms of data scraping. I have gotne to a point wherei can use it to
    submit form details.
    I need to scrape data from the tables etc. How do i do it.
    For eg my if ie is my browser object, how do i get the tables in the
    page and extract data from 3 table in the page into a array?

    Pl help.

    Seede
     
    , Jul 8, 2006
    #1
    1. Advertising

  2. Xavier Noria Guest

    On Jul 8, 2006, at 19:25, wrote:

    > Hi
    > I found Watir and am excited to use it. I cannot find much examples in
    > terms of data scraping. I have gotne to a point wherei can use it to
    > submit form details.
    > I need to scrape data from the tables etc. How do i do it.
    > For eg my if ie is my browser object, how do i get the tables in the
    > page and extract data from 3 table in the page into a array?


    Watir is a wrapper around MSIE. In my limited experience crawling
    with Watir, besides reading its documentation I think it's good to
    study the underlying API, available here:

    http://msdn.microsoft.com/library/default.asp?url=/workshop/
    browser/mshtml/reference/reference.asp

    In particular the interfaces IWebBrowser2, IHTMLDocument2, and
    IHTMLDocument3:

    http://msdn.microsoft.com/workshop/browser/webbrowser/reference/
    ifaces/iwebbrowser2/iwebbrowser2.asp
    http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/
    document2/document2.asp
    http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/
    document3/document3.asp

    There you see what can be done grabbing the ie attribute of the
    Watir::IE object, in case the wrapping interface does not address
    some particular need. Additionally, I have found reading watir.rb
    very instructive, you have a better knowledge of what you are doing
    and may give context and idioms.

    -- fxn
     
    Xavier Noria, Jul 8, 2006
    #2
    1. Advertising

  3. James Britt Guest

    Xavier Noria wrote:
    > On Jul 8, 2006, at 19:25, wrote:


    > There you see what can be done grabbing the ie attribute of the
    > Watir::IE object, in case the wrapping interface does not address some
    > particular need. Additionally, I have found reading watir.rb very
    > instructive, you have a better knowledge of what you are doing and may
    > give context and idioms.


    About a year or so ago I poked around trying to get HTML from IE in
    Watir. The problem (and maybe this has changed) was that the IE object
    did not have a way to get the literal text currently in the browser;
    there was no COM 'view|source', so to speak.

    What it exposed was access to IE's internal node tree, which is *not*
    what is in the browser. IE adds all sorts of things (for DHTML and such,
    as well as, I think, the various implied attributes defined in the HTML
    DTD. Something akin to the post-schema infoset, I think.) so it is
    useless for verifying server output. Still, it is handy in other ways;
    you can locate, say, table elements and td content and so on.

    I wrote a method that did a recursive walk down the internal IE tree and
    created an XML string from it. Contact me off-list if you would like me
    to send it to you. It's old and may not work with the current Watir,
    but might give you some ideas.

    james DOT britt AT gmail DOT com

    --
    James Britt

    http://www.ruby-doc.org - Ruby Help & Documentation
    http://www.artima.com/rubycs/ - The Journal By & For Rubyists
    http://www.rubystuff.com - The Ruby Store for Ruby Stuff
    http://refreshingcities.org - Design, technology, usability
     
    James Britt, Jul 8, 2006
    #3
  4. Xavier Noria Guest

    On Jul 8, 2006, at 22:04, Xavier Noria wrote:

    > On Jul 8, 2006, at 19:25, wrote:
    >
    >> Hi
    >> I found Watir and am excited to use it. I cannot find much
    >> examples in
    >> terms of data scraping. I have gotne to a point wherei can use it to
    >> submit form details.
    >> I need to scrape data from the tables etc. How do i do it.
    >> For eg my if ie is my browser object, how do i get the tables in the
    >> page and extract data from 3 table in the page into a array?


    > There you see what can be done grabbing the ie attribute of the
    > Watir::IE object, in case the wrapping interface does not address
    > some particular need. Additionally, I have found reading watir.rb
    > very instructive, you have a better knowledge of what you are doing
    > and may give context and idioms.


    By the way, regarding the question about tables you can do this:

    table = ie.table:)index, 3)

    That index is 1-based and returns an object of type Watir::Table or
    nil. As per the definition of order between tables, it is delegated
    to IE this way:

    @ieController.document.getElementsByTagName("TABLE")

    -- fxn
     
    Xavier Noria, Jul 9, 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. metfan
    Replies:
    2
    Views:
    4,874
    Robert Olofsson
    Oct 21, 2003
  2. Colin J. Williams

    Webchecker Usage - a problem with local usage

    Colin J. Williams, Feb 25, 2004, in forum: Python
    Replies:
    1
    Views:
    565
    Colin J. Williams
    Feb 26, 2004
  3. hvt
    Replies:
    0
    Views:
    1,229
  4. hvt
    Replies:
    0
    Views:
    1,516
  5. Anukul Singhal
    Replies:
    1
    Views:
    181
    Charley Baker
    May 15, 2008
Loading...

Share This Page