Jump to content
ChipConnJohn

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

 

Share this post


Link to post
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.

Share this post


Link to post
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

  • Similar Content

    • By zuladabef
      I want to set the value of a input, but I only have the input name and input id.  I cannot find a form in the source.  Form collection does not return any results.  
      Is there a way to use FormElementSetValue without a form name? Can I use _IEGetObjByName or _IEGetObjById?  If so, how do I set the value once I have the object? Where do I go from here? Local $oIE = _IEAttach("[Website Goes Here"]) Local $oForm = _IEFormGetCollection($oIE, 1) Local $oQuery = _IEFormElementGetCollection($oForm, 4) _IEFormElementSetValue($oQuery, "Set it to this")  
    • By Seminko
      Hey there,
      below function returns an "object collection" (not sure if that's the correct term) of 'a' elements grabbed from within //*[@id="J_DetailMeta"].
      However, I need the returned collection not to include objects with 'aria-disabled = true'. Is there a way of removing specific objects from such a collection?
      Func GetObjectList($sPicker) $oDetailMeta = _IEGetObjById($oIE, "J_DetailMeta") If Not @error Then $tags = $oDetailMeta.GetElementsByTagName("ul") For $tag in $tags $data_ID_value = $tag.GetAttribute("data-property") If $sPicker = "color" Then If $data_ID_value = '????' Or $data_ID_value = "????" Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "network" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "storage" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf EndIf Next EndIf Return $oReturnList EndFunc $oColorList = GetObjectList("color") For $oColor In $oColorList If StringInStr($oColor.GetAttribute("aria-disabled"), "true") <= 0 Then ; remove object from the collection ??? EndIf Next  
    • By careca
      Hi, i feel im close to getting it to work, but there must be something im missing that's probably easy for you experts.
      #include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> $Visible = 1 Local $oIE $oIE = _IECreate("https://beemp3s.net/mp3-download.html", 0, $Visible, 1, 1) _IELoadWait($oIE) If $oIE <> @error Then ;_ArrayText() _QuerySite('Finding Hope - Without You') ;_IEQuit($oIE) ;Exit Else MsgBox(64 + 262144, 'Fail', 'Could not create a new window') EndIf ;============================================================================= Func _QuerySite($Name) Local $oIE_ObjectToSearch = _IEGetObjById($oIE, 'query') _IEDocInsertText($oIE_ObjectToSearch, $Name) Local $oIE_ObjectToClick = _IEGetObjById($oIE, "search-action") _IEAction($oIE_ObjectToClick, 'click') _IELoadWait($oIE, 2000) ;============================================================================= Local $oSubmitClick = _IEGetObjById($oIE, "col-md-12") _IEAction($oSubmitClick, "click") _IELoadWait($oIE, 2000) ;============================================================================= Local $oBtns = _IETagNameGetCollection($oIE, "div") For $oBtn In $oBtns If String($oBtn.classname) = "col-md-12" Then If String($oBtn.innertext) = "Download / Play" Then ConsoleWrite($oBtn.innertext & @CRLF) _IEAction($oBtn, 'click') EndIf EndIf Next ;============================================================================= ;Local $oElements = _IETagNameAllGetCollection($oIE) ;For $oElement In $oElements ; If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText) ;Next ;============================================================================= ;_IEQuit($oIE) ;Exit ;============================================================================= EndFunc ;==>_QuerySite ;============================================================================= Func _ArrayText() If FileExists('Titles.txt') Then Local $FO = FileOpen('Titles.txt') Local $R2A = FileReadToArray($FO) Local $iLineCount = @extended FileClose($FO) For $f = 0 To $iLineCount - 1 ConsoleWrite($f & ' - ' & $R2A[$f] & @CRLF) _QuerySite($R2A[$f]) Next Else MsgBox(64 + 262144, 'Fail', 'Could not find the file Titles.txt') EndIf EndFunc ;==>_ArrayText ;============================================================================= The idea is to get into this site, write into the search and click, which i did, but now the problem is clicking in any of the buttons in the results page, im looking for a way to click the first one, it always matches to what i want, so no need to fiddle around.
      Site
      Thanks for help in advance.

    • By yoschga
      is there a possibility to let ie.au3 click into a form? i use on a project where i need to click into a form where items are loaded just writing it in or fill the form is no option
       

    • By RamaKrishna9
      What are the minimum system requirements(like Windows OS version, IE browser version, etc,.) for IE.au3(3.3.14.2) to work properly?
×
×
  • Create New...