【发布时间】:2019-11-14 10:36:37
【问题描述】:
我正在尝试从此处的表中获取有关 XAU 价格的数据:https://www.investing.com/currencies/xau-pln-historical-data
我需要在谷歌表格中有数据,问题是它不刷新数据。当我手动清理单元格并插入公式时,数据会被刷新,但是当我使用脚本执行它时它不起作用。我有这个脚本(基于https://support.geckoboard.com/hc/en-us/articles/206260188-Use-Google-Sheets-ImportHTML-function-to-display-data-in-Geckoboard):
function getData2() {
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Rank");
var cellFunction = '=INDEX(IMPORTHTML("https://www.investing.com/currencies/xau-pln-historical-data","table",1),2,2)';
var PricesRange = sheetName.getRange('K2:K14');
PricesRange.clearContent();
var queryString = Math.random();
for (var j = 2; j <= 14; j++) {
var cellFunction2 = '=INDEX(IMPORTHTML("https://www.investing.com/currencies/xau-pln-historical-data","table",1),' + j + ',2)';
sheetName.getRange(j,11).setValue(cellFunction2);
}
}
我设置了一个触发器,它每分钟运行一次脚本,但数据仍然相同。
你有什么想法吗?
【问题讨论】:
-
您好汉娜,我的回答是否帮助您解决了您的问题?请告知,谢谢
标签: javascript google-apps-script google-sheets refresh