I created a script to return some credit card informations from an internal website
<a href=\"/web/Support.aa/aa/g55erefesfsfsf/4.g.g.5.24.54\">
CC<br>Info
</a>
", "
Visa (9999)
", "
Visa (8888)
", "
Visa (7777)
", "
Visa (666)
", "
Alipay
", missing value, missing value, missing value}
I have two issue with my script,
-
I can't get rid of the first link with is not a CC numbers
tried :
set myRawData to items 2 thru -1 of myRawData as string
but don't seems to work. -
I don't manage to remove all the missing values.
-
Can I remove some entry from the list that contain "none" ?
Here is my full script
tell application "Google Chrome"
tell active tab of window 1 to set myRawData to execute javascript "var outPut=[]; var arr=document.getElementsByClassName('sortable fraudScoringTransactionCCSummary');for (var i in arr) {outPut.push(arr[i].innerHTML)};outPut;"
end tell
## set myRawData to items 2 thru -1 of myRawData as string -- not working
set myNewList to {}
repeat with each from 1 to count of items of myRawData
set itemOnMyList to item each of myRawData
if itemOnMyList is in myRawData and itemOnMyList is not in myNewList then set end of myNewList to itemOnMyList
end repeat
## not sur
##set myNewList to items 2 thru -1 of myNewList -- not working
set countHowManyCC to count myNewList
return countHowManyCC
Best Answer
Using the returned output information posted in your OP while adding the missing opening curly brace and a opening double quote
{"
so as to have it compile as alist
, the following example AppleScript code filters out the first item of the list as well as the items containingmissing value
in order to return a count of items that represent the data.The following example AppleScript code adds a second filter to handle items containing "none":
Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways to accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.