1

I need to grab data from a safari, There is a random number of :

document.getElementsByClassName('sortable DataSummary')[1]

this work fine :

tell application "Safari"
    set mzRawData to do JavaScript "var outPut=[]; var arr=document.getElementsByClassName('sortable DataSummary');for (var i in arr) {outPut.push(arr[i].innerHTML)};outPut;" in current tab of window 1
end tell

the return is a bit annoying with some space and line e.g :

>  ", "
>                                 
>                                     WeChat Pay
>                                 
>                             ", "

My question :

How can I do the same using an AppleScript repeat statement ? This is not working but here is my draft at the moment

set mzRawData to ""

repeat with i from 1 to count of items of mzRawData

    tell application "Safari"
        do JavaScript "document.getElementsByClassName('sortable DataSummary')[" & i & "].innerHTML;" in current tab of window 1

    end tell

end repeat

and

set mzRawData to ""
set myNewList to {}
repeat until mzRawData contains "current application"
    tell application "Safari"
        do JavaScript "document.getElementsByClassName('sortable DataSummary')[" & i & "].innerHTML;" in current tab of window 1
        set itemOnMyList to item each of mzRawData
        if itemOnMyList is in mzRawData and itemOnMyList is not in myNewList then set end of myNewList to itemOnMyList  
    end tell
end repeat

You must log in to answer this question.

Browse other questions tagged .