langthang084 Posted October 24, 2014 Share Posted October 24, 2014 I want to search something on the internet (like Google, Youtube...). And I will get the list of result links. So how to declare each link in the variable? Link to comment Share on other sites More sharing options...
water Posted October 24, 2014 Share Posted October 24, 2014 Depends on the browser you use. IE, FF ...? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jdelaney Posted October 24, 2014 Share Posted October 24, 2014 (edited) Short answer (ie): #include <IE.au3> _IELinkGetCollection(ByRef $o_object [, $i_index = -1]) Will return much more than you want. Long ansower, loop through the above, and grab only the valid ones...they will all follow some pattern. Edited October 24, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
langthang084 Posted October 25, 2014 Author Share Posted October 25, 2014 Thanks! But how to do this with Chrome? Link to comment Share on other sites More sharing options...
langthang084 Posted October 25, 2014 Author Share Posted October 25, 2014 (edited) Here my code with IE, but why I dont use Filter with these link? and dont add $link[$i] to array? #include <IE.au3> #include <Array.au3> #include <File.au3> Local $oIE = _IECreate("http://www.youtube.com/results?search_query=ABCDE") Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended $link = 0 $linkend = 0 Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CRLF Next $Finish = FileOpen("C:\temp.txt", $FO_APPEND + $FO_UTF8) FileWrite($Finish, $sTxt) _FileReadToArray("C:\temp.txt", $link) for $i = 0 to $link[0] if $link[$i] = "http://www.youtube.com/watch?v=" Then _ArrayAdd($linkend, $link[$i]) EndIf Next _ArrayDisplay($linkend, "") Edited October 25, 2014 by langthang084 Link to comment Share on other sites More sharing options...
jdelaney Posted October 27, 2014 Share Posted October 27, 2014 How about: #include <IE.au3> #include <Array.au3> Local $oIE = _IECreate("http://www.youtube.com/results?search_query=ABCDE") Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended $link = 0 $array = "" Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CRLF If StringInStr($oLink.href,"http://www.youtube.com/watch?v=") Then If IsArray($array) Then _ArrayAdd($array, $oLink.href) Else Local $array[1] = $oLink.href EndIf EndIf Next _ArrayDisplay($linkend, "") IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
junkew Posted October 27, 2014 Share Posted October 27, 2014 (edited) some magic in any browser by entering this in the addressbar (google for favlets/bookmarklets) and you read out the alertbox javascript:var list = document.getElementsByTagName("a"); alert([].slice.call(list).toString());void(0); or more subtle thru addressbar and result in a newly created textbox (which you can read thru iuiautomation) javascript: var list = document.getElementsByTagName("a");var textbox = document.createElement('input');textbox.type = 'text';document.body.appendChild(textbox);textbox.value=[].slice.call(list).toString();void(0); be aware that with copy/paste you can loose text: javascript: and with this you can automate all major browsers easily '?do=embed' frameborder='0' data-embedContent>> Edited October 27, 2014 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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