How to grab web data into Numbers sheet
Hello, I am trying to grab the value out of a webpage to paste ir in the Numbers sheet that I am using.
The data is the "Valor Liq." value in the site. Located in the top table.
I found this script from a previous question, but not able to adapt it get what I want.
-- change values between "" in first three lines to match your setup
set mySheetName to "Prices"
set myTableName to "Coin Prices"
set tgtCell to "A2"
set theHtml to do shell script "curl -s " & quoted form of "https://www.worldcoinindex.com"
set text item delimiters to {"<tbody>", "</tbody>"}
set tableContents to theHtml'stext item 2 # item 2 is the body of the price table
set text item delimiters to {"<h2>"} # site uses new h2 for each currency
set tableChunks to tableContents'stext items 2 thru -1
set pasteStr to ""
repeat with aChunk in tableChunks
set text item delimiters to "><span>$ </span><span class=\"span\">"
tell aChunk's text item 1 to set {theSymbol, thePrice} to {first word, last word}
set pasteStr to pasteStr & theSymbol & tab & thePrice & return
end repeat
set the clipboard topasteStr
tell application "Numbers"
tell front document
tell active sheet to set currSheet to its name # save current location
tell sheetmySheetName to tell tablemyTableName
activate
set selection range to rangetgtCell
delay 0.3
tell application "System Events" to keystroke "v" using {option down, shift down, command down}
end tell
activate
set active sheet to sheetcurrSheet# go back to original location
end tell
end tell
Any ideas how to grad the data?
Screenshot of the data:
MacBook Pro 13″, macOS 11.4