Neokil Posted March 7, 2016 Share Posted March 7, 2016 Hello guys, I am quite new to AutoIt and was trying to do some Website-Automation using the IE-Plugin. The Point where I got stuck is when I have to save my data into objects. What I am trying to do is to loop through a collection of Website-Elements and save some informations if the current Element meets a certain condition. It looks like this: Local $DataArray = [0] For $item In _IETagNameGetCollection($IE, "div") If $item.className = "target" Then Local $Data = ??? $Data.Link = $item.href $Data.Description = $item.innerText $DataArray.Push($Data) EndIf Next But as you might already know, it doesnt work like this. First Problem is I cant find a way to create an empty Object to create a structure for my Data. The second one is if I call "$DataArray.Push" it tells me "$DataArray ==> Variable must be of type 'Object'." Anyone there who could tell me how those two things are done in AutoIt? Greetings Neokil Link to comment Share on other sites More sharing options...
JohnOne Posted March 7, 2016 Share Posted March 7, 2016 AutoIt does not natively support arbitary objects like that, perhaps you could use a scripting dictionary, or a map in beta version. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mikell Posted March 7, 2016 Share Posted March 7, 2016 This looks a lot like a map indeed. Why not a simple 2D array ? Link to comment Share on other sites More sharing options...
Neokil Posted March 7, 2016 Author Share Posted March 7, 2016 So if I get it right you suggest something like this? Local $DataArray = [0] For $item In _IETagNameGetCollection($IE, "div") If $item.className = "target" Then Local $Data[2] $Data[0] = $item.href $Data[1] = $item.innerText $DataArray.Push($Data) EndIf Next This solved the first problem I had, but "$DataArray.Push" is still throwing the same exception. Link to comment Share on other sites More sharing options...
mikell Posted March 7, 2016 Share Posted March 7, 2016 Maybe something like this ? (untested) $oDivs = _IETagNameGetCollection($IE, "div") $count = @extended Local $DataArray[$count][2], $i = 0 For $item In $oDivs If $item.className = "target" Then $Data[$i][0] = $item.href $Data[$i][1] = $item.innerText $i += 1 EndIf Next Redim $DataArray[$i-1][2] Link to comment Share on other sites More sharing options...
Neokil Posted March 7, 2016 Author Share Posted March 7, 2016 Thanks, it worked beautifully 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