Follow-up of
Recently I have found that many "bad" questions about importing Yahoo Finance data into Google Sheets by using IMPORTHTML / IMPORTXML built-in functions have very similar answers.
- It's not possible by using Google Sheets built-in functions
- Include a suggestion of using Google Apps Script to parse JSON included in the source file
Usually the scripts are tailored to the specific OP requirements. Very rarely do they make reference to another post so in the best cases we have a lot of answers repeating again and again the same explanations and in the worst cases there isn't any hint or guidance about how to adapt the script to similar cases.
Considering the above, I as a google-sheets gold-tag badge holder, am wondering which could be the best question to be used as the duplicate target for questions repeating the same pattern (in short, the OP didn't followed the Ask Question Wizard):
- The OP used the web browser developers tools wrongly to get the index of the table, list or xPath of the text to be imported.
- Used the Elements tab to get the xPath from the rendered DOM
- Used the web browser console to execute some JavaScript code to get data from the rendered DOM
- The above is wrong because Google Sheets built-in functions can see only the source code of the main file, it can't execute JavaScript / do additional network calls to load data.
- There is one or more formulas using IMPORTHTML or IMPORTXML
- Sometimes the OP mentions the error message displayed in the spreadsheet.
Here is a search to look to related questions:
[google-sheets] [yahoo-finance] duplicate:0 answers:1 returns 42 results
Other searches
- finance.yahoo.com [google-sheets] duplicate:0 returns 77 questions
- url:finance.yahoo.com [google-sheets] duplicate:0 returns 32 questions
Looking at several answers that suggested to use Google Apps Script instead of Google Sheets built-in functions most of them are not working as of January 4th 2023. At first I thought that it might caused because a change on the elements id, class names or other DOM changes that affecting the xPath.
There are reports that Yahoo! Finance started to encrypt the JSON included in the https://finance.yahoo.com. I found a mention of this situation here in Tainake's answer to How to pull Yahoo Finance Historical Price Data from its Object with Google Apps Script?. This question is slightly different as it's not about using Google Sheets built-in functions but it's a follow-up question of a question posted one year ago about using Google Apps Script for web scraping but is still relevant as most of the workarounds offered on the answers pointed to the same type of script.
Some questions having answers working on January 5th 2024
Historical data
- How to import historical data (CSV) from Yahoo Finance in SpreadSheets
- Xpath data extraction from yahoo finance table
- Get information from Yahoo Finance
- Resource URl Not Found with Yahoo Finance
Other
- Import data from yahoo finance to Google sheets
- The answer to this questions uses a URL that delivers historical data as CSV (a similar URL as the used on the first question on this list). It's not what the OP was asking. Closed as duplicate of **
** Scraping data to Google Sheets from a website that uses JavaScript
Resources
Related