我尝试为APPLE导入历史数据(CSV)。我在Google工作表中使用ImportData函数
https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1577982443&period2=1609604843&interval=1d&events=history&includeAdjustedClose=true
但结果是"#N/A"。
我想得到的CSV,因为有3位小数。而只有2,在网站上。
=IMPORTXML("https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1577982443&period2=1609604843&interval=1d&events=history&includeAdjustedClose=true")
之后有一个脚本来获取文件:AAPL. csv.
你能帮帮我吗?
1条答案
按热度按时间rpppsulh1#
不幸的是,在URL的情况下,
IMPORTDATA
和IMPORTXML
似乎无法使用。但幸运的是,我确认了Google Apps Script的UrlFetchApp
可以检索CSV数据。因此,在此回答中,我想建议使用Google Apps Script来实现您的目标。示例脚本:
请将以下脚本复制粘贴到Google Spreadsheet的脚本编辑器中,并将
=SAMPLE("https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1577982443&period2=1609604843&interval=1d&events=history&includeAdjustedClose=true")
放入单元格中。此脚本用作自定义函数。通过此脚本,可以在单元格中检索CSV数据。结果:
当使用上述脚本时,将获得以下结果。
参考文献: