drego Posted April 29, 2012 Share Posted April 29, 2012 I'm trying to loop through a bunch of links and perform some operations. Here is my code:$oLinks = _IELinkGetCollection($ie1) $iNumLinks = @extended For $oLink In $oLinks If StringInStr($oLink.href,"offerdetails") > 0 Then _IENavigate($ie1,$oLink.href) $html = _IEBodyReadHTML($ie1) $offerName = _StringBetween($html,'DrkBlue">','</') ;MsgBox(0,"offer name",$offerName) EndIf NextThe If statement is evaluating true and it is visiting the first link. However, as soon as it visits the first link my program dies with the error:The requested action with this object has failed.:If StringInStr($oLink.href,"offerdetails") > 0 ThenIf StringInStr($oLink.href^ ERROR Link to comment Share on other sites More sharing options...
drego Posted April 29, 2012 Author Share Posted April 29, 2012 cant sleep until i solve this Link to comment Share on other sites More sharing options...
DaleHohm Posted April 30, 2012 Share Posted April 30, 2012 As soon as you use _IENavigate, the current document and all of it's objects are destroyed (including $oLinks), so when it tries to loop again, neither $oLinks nor $oLink is valid any longer. Perhaps you want to open a second browser and send your navigation to that browser so that your original context is preserved or perhaps you want to store all of the hrefs in an array and then loop through it... depends on what you are trying to accomplish. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
drego Posted April 30, 2012 Author Share Posted April 30, 2012 As soon as you use _IENavigate, the current document and all of it's objects are destroyed (including $oLinks), so when it tries to loop again, neither $oLinks nor $oLink is valid any longer.Perhaps you want to open a second browser and send your navigation to that browser so that your original context is preserved or perhaps you want to store all of the hrefs in an array and then loop through it... depends on what you are trying to accomplish.DaleI think I would like to store them all in an array Link to comment Share on other sites More sharing options...
drego Posted April 30, 2012 Author Share Posted April 30, 2012 im having trouble creating the array. how should I do it? Link to comment Share on other sites More sharing options...
drego Posted April 30, 2012 Author Share Posted April 30, 2012 this is all wrong $oLinks = _IELinkGetCollection($ie1) $iNumLinks = @extended Local $linkAr[$iNumLinks] $place = 0 For $oLink In $oLinks If StringInStr($oLink.href,"offerdetails") > 0 Then ;_IENavigate($ie1,$oLink.href) ;_ArrayAdd($linkAr,$oLink.href) $linkAr[$place] = $oLink.href $place = $place + 1 ;$html = _IEBodyReadHTML($ie1) ;$offerName = _StringBetween($html,'DrkBlue">','</') ;MsgBox(0,"offer name",$offerName) MsgBox(0,"",$linkAr[4]) EndIf Next Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now