HTML DOM parser?

Daniel E. Burrow danieleburrow at yahoo.com
Fri Jul 19 14:15:48 EDT 2002


"David LeBlanc" <whisper at oz.net> wrote in message news:<mailman.1027042346.14070.python-list at python.org>...
> adding time.sleep(2) made it work - gave the browser time to _have_ a
> document :-)
> 
> David LeBlanc
> Seattle, WA USA
> 
> > -----Original Message-----
> > From: python-list-admin at python.org
> > [mailto:python-list-admin at python.org]On Behalf Of David LeBlanc
> > Sent: Thursday, July 18, 2002 18:11
> > To: Paul Rubin; python-list at python.org
> > Subject: RE: HTML DOM parser?
> >
> >
> > > The exception might be legitimate, because of the 403 error.  Try
> > > www.yahoo.com instead of www.nightsong.com.  www.nightsong.com really
> > > does return a 403.
> > > --
> >
> >
> > Nope - it's the call to ie.document that chokes. ie.navigation does open
> > www.w3.org just fine, but trying to get to the DOM isn't working.
> >
> > It looks like there's no attribute "document" for this interface...
> >
> > Dave LeBlanc
> >
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list

Greetings!

I still get the exception if I don't use the ".Document" reference. My
code is suppose to wait for IE to return a "not busy" result before
going on.

I recall Mr. Hammond giving an example where he was waiting for IE's
"ReadyState" to return what would be true when ready state was
obtained. I used to use a method to determine ready state and then go
on to determine if IE was "Busy". I found that using the "Navigate2"
method seemed to obviate the need for checking IE's ready state.
Perhaps I should leave the ready state method in?

Here are a few snippets:

################## start of snips #####################

In main I call:

            o_AleApp.NavigateIE(s_URL)
            ##fire events after nav test
            o_AleApp.ClickCrossFrameElement(1, 'Sub1t')

In NavigateIE I run:

    def NavigateIE(self, s_URL):
        i_Sleep = self.GetDelaySecondsBetweenPageNavs()
        print "Class: AleAppWebReporter Method: NavigateIE: Sleeping",
i_Sleep, "seconds prior to navigating..."
        time.sleep(i_Sleep)
        print "Class: AleAppWebReporter Method: NavigateIE: Navigating
to:\n" + s_URL
        self.o_IE.Navigate2(s_URL)
        ##now lets make sure the page has fully loaded                
        s_NotBusy = self.WaitForNotBusy()
        if s_NotBusy == 'TRUE':
            return 'TRUE'
        else:
            return s_NotBusy

In WaitForNotBusy I run:

    def WaitForNotBusy(self):
        print "Class: AleAppWebReporter Method: WaitForNotBusy:
Current URL:", self.GetIELocationURL()
        i_IEBusy = int(self.GetIEBusy())
        print "Class: AleAppWebReporter Method: WaitForNotBusy:
i_IEBusy:", i_IEBusy
        if i_IEBusy != 1:
            return 'TRUE'
        else:
            i = 1
            i_State = 0
            while i_State == 0:
                print "Class: AleAppWebReporter Method:
WaitForNotBusy: Waited:", i, "seconds for IE to complete
downloading..."
                time.sleep(1)
                i_IEBusy = int(self.GetIEBusy())
                print "Class: AleAppWebReporter Method:
WaitForNotBusy: i_IEBusy:", i_IEBusy
                if i_IEBusy != 1:
                    i_State = 1 
                i += 1
            return 'TRUE'

In GetIEBusy I run:

    def GetIEBusy(self):
        return self.o_IE.Busy

################## end of snips #####################



More information about the Python-list mailing list