jacob_1998_1999 Posted July 15, 2006 Share Posted July 15, 2006 ; ******************************************************* ; Example 1 - Open browser with basic example, get link collection, ; loop through items and display the associated link URL references ; ******************************************************* ; #include <IE.au3> $oIE = _IE_Example ("basic") $oLinks = _IELinkGetCollection ($oIE, -1) $iNumLinks = @extended MsgBox(0, "Link Info", $iNumLinks & " links found") For $oLink In $oLinks MsgBox(0, "Link Info", $oLink.href) Next ------------- Would it be possible to get an example showing the index Number with the URLs, and perhaps print them to a file? Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 15, 2006 Author Share Posted July 15, 2006 Would it be possible to get an example showing the index Number with the URLs, and perhaps print them to a file? Simple way I thought to do this, Not sure if it is 100% correct.. And I will need to do a tad more research to save to a file again. ; ******************************************************* ; Example 1 - Open browser with basic example, get link collection, ; loop through items and display the associated link URL references ; ******************************************************* ; #include <IE.au3> $oIE = _IE_Example ("basic") $oLinks = _IELinkGetCollection ($oIE, -1) $iNumLinks = @extended MsgBox(0, "Link Info", $iNumLinks & " links found") $oIndexNumber = -1 For $oLink In $oLinks $oIndexNumber = $oIndexNumber + 1 MsgBox(0, "Link Info", $oLink.href & " " & $oIndexNumber) Next Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 15, 2006 Author Share Posted July 15, 2006 (edited) Yet again, Modified Example. ; ******************************************************* ; Example 1 - Open browser with basic example, get link collection, ; loop through items and display the associated link URL references ; ******************************************************* ; #include <IE.au3> $oIE = _IE_Example ("basic") $oLinks = _IELinkGetCollection ($oIE, -1) $iNumLinks = @extended MsgBox(0, "Link Info", $iNumLinks & " links found") $oIndexNumber = -1 $file = FileOpen("LinkIndexs.txt", 1) For $oLink In $oLinks If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $oIndexNumber = $oIndexNumber + 1 ;MsgBox(0, "Link Info", $oLink.href & " " & $oIndexNumber) FileWrite($file, $oLink.href & " " & $oIndexNumber & @CRLF) Next FileClose($file) Edited July 15, 2006 by jacob_1998_1999 Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 15, 2006 Author Share Posted July 15, 2006 I have gotten everything that I wanted from LinkClickByIndex -- Other than the fact that it Does NOT work (to my knowledge) When the window is brought up from the _IEcreate("http://www.Google.com", 0,0) method. Am I going about this wrong.. Or am I trying to write my project to do something that is means are not capable for yet? Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 15, 2006 Author Share Posted July 15, 2006 Perhaps found my problem.. $oButton = _IEFormElementGetObjByName($oForm, "submit") $oButton.focus() Send("{Enter}") This does not go through in the "hidden" state. HTML of the Form I am trying to get through. <tr><td>Username:</td><td><input name=username></td></tr> <tr><td>Password:</td><td><input type=password name=password></td></tr> <tr><td></td><td><input name=submit class=submit type=submit value='log in'</td></tr> Can anyone think of another way to get into it? Link to comment Share on other sites More sharing options...
Andrew Sparkes Posted July 15, 2006 Share Posted July 15, 2006 (edited) Use _IEFormSetElementValue() and _IEFormSubmit() check IE.au3 ... Make $form,$username,$password obj references to the form and the inputs, respectively. _IEFormSetElementValue($username,'username') _IEFormSetElementValue($password,'password') _IEFormSubmit($form) EDIT: To hit the submit button, try _IEClickLinkByText() I think that's what it's called... Sparkes. Edited July 15, 2006 by Andrew Sparkes ---Sparkes. Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 15, 2006 Author Share Posted July 15, 2006 I just changed the .focus() + ENTER to $oButton.click() worked. With the page I am dealing with the Index is prefered over the LinkClickByName -- Because several of the links are named the same. Link to comment Share on other sites More sharing options...
Andrew Sparkes Posted July 15, 2006 Share Posted July 15, 2006 If you need to, just do a regex on it. That would be the simplest way... You could just parse out the link url of the link you are looking for... Sparkes. ---Sparkes. Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 15, 2006 Author Share Posted July 15, 2006 (edited) I Do need to use a Regex for another part in this script.. But sadly I know nothing about regex at all.. A example of why I would need it is as follows: <a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a> I would like to search the entire page for all "/attack.php?UID=" yet.. Exclude 2 specific ones.. And Simulate a click on links that are avaliable that are not the 2 I specify. Is that confusing enough? Sorry for going off topic. EDIT: of <a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a> I only need to actually search for "attack.php?UID=###&" Edited July 15, 2006 by jacob_1998_1999 Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 16, 2006 Moderators Share Posted July 16, 2006 I Do need to use a Regex for another part in this script.. But sadly I know nothing about regex at all.. A example of why I would need it is as follows: <a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a> I would like to search the entire page for all "/attack.php?UID=" yet.. Exclude 2 specific ones.. And Simulate a click on links that are avaliable that are not the 2 I specify. Is that confusing enough? Sorry for going off topic. EDIT: of <a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a> I only need to actually search for "attack.php?UID=###&"This should get you started: Requirements: Latest Beta #include <IE.au3> #include <Array.au3> Dim _ $i = 0, _ $aLinks[1], _ $sExclude1 = "whatever1", _ $sExclude2 = "whatever2", _ $sInclude = "attack.php?UID=", _ $sURL = "www.your-webpage.com" $oIE = _IECreate ($sURL) ; Get a collection all all links $oLinks = _IELinkGetCollection ($oIE) ; Loop through all links For $oLink In $oLinks ; Get the href value for the current link $sHREF = $oLink.href ; Check that it matches the type of links we are looking for If StringInStr($sHREF, $sInclude) Then ; Check that it do not include our excluded strings If Not StringInStr($sHREF, $sExclude1) And StringInStr($sHREF, $sExclude2) Then ReDim $aLinks[$i + 1] ; Build an array of all links that passed our test $aLinks[$i] = $sHREF $i += 1 EndIf EndIf Next _ArrayDisplay($aLinks, "Matching Links") Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 16, 2006 Author Share Posted July 16, 2006 (edited) This should get you started:That... Is beautiful man. *sheds a tear* Thank you so much..Wow, Just ty. One problem.. Something is missfiring.. I'll upload an Example.html and a little script. Edited July 16, 2006 by jacob_1998_1999 Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted July 16, 2006 Author Share Posted July 16, 2006 Promised files are attached. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 16, 2006 Moderators Share Posted July 16, 2006 I forgot to add the second not. Change this: If Not StringInStr($sHREF, $sExclude1) And StringInStr($sHREF, $sExclude2) Then 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