Tardis Posted January 26, 2018 Posted January 26, 2018 Hi All I have not used Autoit in a log time and just doing some simple coding lot of changes since i was here last any how can some help me with this code why am I getting a blank array ? expandcollapse popup#include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <String.au3> Local $oIE = _IECreate("http://www.harryhomers.org/et/forum/viewtopic.php?f=89&t=7858", 0, 0, 1, 0) Local $oDiv = _IEGetObjById($oIE, "post_content63721") Local $ListArray[0] ,$sHTML = BinaryToString($oDiv.innertext) ;Test $sHTML MsgBox($MB_SYSTEMMODAL, "sHTML", $sHTML) For $i = 1 To 20 $aNames = _StringBetween($sHTML, ">" & $i & ". ", "<") If IsArray($aNames) Then _ArrayAdd($ListArray, $aNames[0]) Next _ArrayDisplay($ListArray) ;Debug Test ConsoleWrite($sHTML&@CRLF) #comments-start ;Should list in the array 1. baserace_b3c 2. bulge_beta1 3. __BRIDGES__ 4. airassault_fp1 5. oasis_winter 6. 1944_siegfried 7. supplydepot3 8. 1944_nordwind 9. transmitter 10. frostbite 11. Alps_trail 12. wolfsrudel_final 13. wolken3_final 14. stalingrad 15. et_ice 16. v1rocket_b2 17. Teutoburg_Forest 18. mcassino 19. lp1_2 20. frost2_final #comments-end
mikell Posted January 26, 2018 Posted January 26, 2018 (edited) Hehe, innertext returns the text without the html tags so your StringBetween can't work Use this instead $sHTML = $oDiv.innerhtml and it will roll on nice Edited January 26, 2018 by mikell krista611 1
Tardis Posted January 26, 2018 Author Posted January 26, 2018 Hi Mikel Thank you for the help but I changed that to what you said and the array is still blank So Code Change of line 7 to Local $ListArray[0] ,$sHTML = $oDiv.innerhtml I also tried $ListArray[0] , $sHTML = BinaryToString($oDiv.innerhtml) and still Blank array
mikell Posted January 27, 2018 Posted January 27, 2018 Strange. This works well for me #include <IE.au3> #include <Array.au3> #include <String.au3> Local $oIE = _IECreate("http://www.harryhomers.org/et/forum/viewtopic.php?f=89&t=7858", 0, 0, 1, 0) Local $oDiv = _IEGetObjById($oIE, "post_content63721") Local $ListArray[0] , $sHTML = $oDiv.innerhtml ; MsgBox(0, "sHTML", $sHTML) For $i = 1 To 20 $aNames = _StringBetween($sHTML, ">" & $i & ". ", "<") If IsArray($aNames) Then _ArrayAdd($ListArray, $aNames[0]) Next _ArrayDisplay($ListArray) This one could be faster though #include <Array.au3> $sHTML = BinaryToString(InetRead("http://www.harryhomers.org/et/forum/viewtopic.php?f=89&t=7858", 1)) $ListArray = StringRegExp($sHTML, '(?m)^\d+\. ([^<]+)', 3) _ArrayDisplay($ListArray) Tardis 1
Tardis Posted January 27, 2018 Author Posted January 27, 2018 (edited) Thanks Mikell the second code is much neater and lot cleaner works like a charm also helps with the #include <InetConstants.au3> The top one just gives me a blank array OS = Win 10 X64 SciTE Version 3.7.3 Autoit 3.3.14.2 Hence Why i am confused . I plan to use the array to get the info then download the files needed. Edited January 27, 2018 by Tardis Edit
mikell Posted January 28, 2018 Posted January 28, 2018 I don't know why the first code doesn't work for you, sorry You might use a visible IE window and do some step-by-step debug to check every data Anyway this site is easy to browse so the basic Inet* functions work nice in this case Local $var = "__BRIDGES__", $file = $var & ".pk3" Local $downloadurl = "http://www.harryhomers.org/et/download/etmain/" InetGet($downloadurl & $file , @scriptdir & "\" & $file) #cs For $i = 0 to UBound($ListArray)-1 Local $file = $ListArray[$i] & ".pk3" InetGet($downloadurl & $file , @scriptdir & "\" & $file) Next #ce A cute addition could be to make a progressbar (InetGetInfo and InetGetSize based) , there are several scripts on the forum
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