Jump to content

IE - StringBetween Array


Tardis
 Share

Recommended Posts

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 ?

#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

Link to comment
Share on other sites

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 :'(

 

 

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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

Blank Array.png

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 by Tardis
Edit
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...