Looking for a way to get the stock price for a specific date (eg. 31.1.2020).
I know I can use IMPORTHTML
or IMPORTXML
together with INDEX
to get the table. However, when I use the browser to search for a specific date on investing.com, there's no direct URL for the date, and it rather presents me with the latest stock prices instead. This is the stock I'm looking for

- 34,714
- 9
- 70
- 166

- 1,911
- 1
- 14
- 23
2 Answers
I'm afraid that investing.com do not provide an API
https://www.investing-support.com/hc/en-us/articles/115005473825-Do-you-provide-an-API-
So you won't be able to do this very easily (if at all) with Google Sheets or Apps Script. The reason is that it looks like most of the content on the site is generated with JavaScript, and so it is not part of the original HTML that is shown when you first enter the site. The HTML is what IMPORTHTML
gets.
To get the information you are looking for without using and API, would involve browser automation. That is, simulate the clicks that a user might make and then get the data. This can be very finicky and is prone to break whenever the website changes its layout or HTML for whatever reason (something that tends to happen quite often for busy websites).
I would recommend using a different service that has a Sheets friendly HTML format. Better than that, I would look into a service that has an API and interact with it with Apps Script. Finally, if you need it to be investing.com you could look into something like Puppeteer which can automate a browser (though its a fair bit more complex than a formula or an API).

- 6,169
- 2
- 12
- 24
-
thx for the info. Unfortunately, there's not enough services that track historical data on that specific stock. I've asked [another question](https://stackoverflow.com/questions/66518686) regarding a different service which I'm having issues scrapping. – Maxim_united Mar 08 '21 at 12:38
You can import using importhtml
the historical data for the last 30 days, and then use a lookup for that data.
To get historical data I use:
query(IMPORTHTML("https://investing.com/equities/STOCK-historical-data"; "table"; 2);"SELECT Col1, Col2")
I don't know if you can import more than 30, I'm searching for that answer myself.