Jump to content

IE.au3 Obj seems to be disappearing?


Recommended Posts

Hello all,

Here's a cleaned up version of my code:

#include <IE.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <String.au3>
;#include <ErrorHandler.au3>

; Open Greatsite.com
Global $oIE = _IECreate ("http://www.greatsite.com")

; I'm logged in and on the forum page.  Now to navigate categories with unknown names.
; Grab all links on page, then only dive into the ones with the text "forum_id="
; as in ?bview=forum&forum_id=108343

Global $oLinksCategoryPage = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

        ;Now at the thread level. Navigate into each thread and look at timestamp
        Global $oLinksOfThreads = _IELinkGetCollection($oIE)
        For $oLinkThread In $oLinksOfThreads
            If StringInStr($oLinkThread.href,"thread_id") Then
                _IENavigate($oIE, $oLinkThread.href)
                ;Need to find instance of Posted and read text after the href.
                Local $sBodyText = _IEBodyReadText($oIE)
                ;Find first instance of the word "Posted" and check the two words to the right of it.
                Local $aArrayOfBodyText = _StringExplode($sBodyText," ",0)
                ;_ArrayDisplay($aArrayOfBodyText, "The body text in Array form")
                ;Local $iIndexOfPosted = _ArraySearch($aArrayOfBodyText,"days")
                For $iIndex = 0 to ubound($aArrayOfBodyText) - 1
                    If StringInStr(StringLower($aArrayOfBodyText[$iIndex]), "posted") Then
                        ;The word Posted has been found. Look for "Just A moment ago", "minutes", and "minute"
                        Select
                            Case StringLower($aArrayOfBodyText[$iIndex +1]) = "just"
                                ;"Just a moment ago.  Grab this one.
                            Case Stringlower($aArrayOfBodyText[$iIndex +2]) = "minute"
                                ;"1 minute". Grab this one
                            Case Stringlower($aArrayOfBodyText[$iIndex +2]) = "minutes"
                                ;"x minutes. Grab this one
                        EndSelect
                        ;ExitLoop ;Found the first one.  I'm done.
                    EndIf
                ;Need to back out to Threads in Category
                Next
                _IEAction($oIE,"back")
            EndIf
        Next
        ;Back out to Category List
        _IEAction($oIE,"back")
    EndIf
Next
_IEQuit($oIE)

 

The script works fine until I hit the Next to go back to the For $oLinkThread In $oLinksOfThreads.  Any line that I put after that crashes with an error.  It's like the For loop is going one too many iterations and there is no object in the variable.

The requested action with this object has failed.:
If StringInStr($oLinkThread.href,"thread_id") Then
If StringInStr($oLinkThread^ ERROR

Thanks,

-John

 

Link to comment
Share on other sites

Maybe one of the links doesn't have HREF property. Put a console write check of the $oLinkThread.html

Maybe the Navigate and Back actions are braking it. Instead of working with link objects - put the links as strings in an array and work with that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...