jonson1986 Posted July 25, 2016 Posted July 25, 2016 Hello, I'm having a condition to copy all urls, having same ending and starting pattern, from source code of a specific website, that's why I write autoit codes but it only copy very first matched url and exist. Could you please help me how can I save all the available URLs matching with my pattern given in codes; Here are codes #RequireAdmin #include <Excel.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> Local $oExcel = _Excel_Open() Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Urls.xlsx", True) ProcessClose ( "iexplore.exe") $file = fileopen(@scriptdir & "\source.txt", 10) $IE = _IECreate(_Excel_RangeRead ($oWorkbook1, Default, "A1"), 0, 0 ) $source = _IEDocReadHTML($IE) FileWrite($file, $source) $target_source2 = _StringBetween($source, 'http://example.com/posts/', '/"') If Not @error Then FileWrite (@scriptdir & "\links.txt", 'http://example.com/posts/' & $target_source2[0] & @crlf) EndIf Thanks
AutoBert Posted July 26, 2016 Posted July 26, 2016 If you want all rows of the array $targetsource you must loop through: $target_source2 = _StringBetween($source, 'http://example.com/posts/', '/"') If Not @error Then For $i=0 To UBound($target_source2) -1 FileWrite (@scriptdir & "\links.txt", 'http://example.com/posts/' & $target_source2[$i] & @crlf) Next EndIf
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