Jump to content

Recommended Posts

Posted

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

Posted

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. 

Posted

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]

 

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
  • Recently Browsing   0 members

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