Applescript & Javascript to get number from chrome and give a total
In that absence of the actual URL and what appears to be incomplete output shows in the OP the following example AppleScript code defines r
as a list
and sums its numeric values.
set r to {"<td>4,000.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", "<td>3,800.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", "<td>5,000.00</td><td>JPY</td>", missing value, missing value, missing value}
set theText to Unicode text
property leftEdge1 : "<td>"
property rightEdge1 : "</td>"
set totalValue to 0
repeat with i from 1 to count r
try
set saveTID to text item delimiters
set text item delimiters to leftEdge1
set classValue to text item 2 of item i of r
set text item delimiters to rightEdge1
set singleValue to text item 1 of classValue
set text item delimiters to saveTID
set totalValue to totalValue + singleValue
end try
end repeat
log totalValue
-- Result:
-- 42800
Note: The example AppleScript code is just that and does not employ any other error handling then what's shown 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.