Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BenCD

macrumors newbie
Original poster
Jan 13, 2021
1
0
Hello everyone,



I am writing to you because I am very (very) new to the use of AppleScript and its "programming".

After many hours of unsuccessful research I would really like some help.



I’ll explain you my ‘needs’ by hoping to be as clear as possible.



For three parities, I wish to go "search/retrieve" data on the following site:

https://fr.investing.com/currencies/eur-usd-historical-data (for eur/usd parity)
https://fr.investing.com/currencies/eur-cad-historical-data (for eur/cad parity)
https://fr.investing.com/currencies/eur-aud-historical-data (for eur/aud parity)

For each of the parities I would like to retrieve the following information:



- Last

- Opening

- Higher

- Lower



And this for the last 4 days (at the time I'm writing, from 13/01/21 to 08/01/21).



And "put" these data in a numbers worksheet, in a specific tab (DONNEES), of an already existing Numbers document (path: /Users/Ben/Desktop/DONNEES & GRAPHICS.numbers).

I attach an image of the "shape of the table".

Capture d’écran 2021-01-12 à 21.46.25.png

There, I hope to have been as clear as possible,

Now I know ho to open a Safari Window, and a Numbers document with AppleScript,

But I don't know how to ask AS to get a specific value (how to name it) in the source code,

"<td data-real-value="1,2161" class="redFont">1,2161</td>"

If someone can help me with that...

Thank you so much!

Ben
 
That is apt to problems as you can never be sure if the source code remains stable.

You import the source code as text? I assume you have tried the text item delimiters?
 
Hello,

I know it's been a long while since you posted, however, the design of the site in the link essentially incapacitates even such crude methods as extracting source code with curl. Basically, the element you need is a subelement of "th", named "td". Inspecting the page with WebInspector reveals useful properties inside the "td" subelement, which would allow pegging the logic on them to fetch the displayed rate for every row. However, for some reason, the curl output skips on these properties, and as such, combing the source for the properties is impossible.

A simpler approach would be to download the sheet using the download option they offer, but this requires having an account. If you can sign in, download that report, and the remaining jobs would narrow down to only handling the file locally. The sites dealing with rates, numbers and other numeric data usually allow several formats to download: choose between TSV, CSV or Excel. Next, it's a matter of creating a folder action that would extract table data and append it to any Numbers document, if you use Numbers, or Excel, if Excel (Numbers converts to Excel should you ever need, so a table as basic as in your example should survive the export unharmed).
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.