我在运行宏时收到以下错误消息:
异常:请求https://drive.google.com失败,返回代码403。服务器响应被截断:抱歉...body { font-family:宋体,宋体,...(使用muteHttpExceptions选项检查完整响应)
似乎止步于URLFetchApp函数:
var ss2 = SpreadsheetApp.getActive();
var url2 = 'https://drive.google.com/uc?export=download&id=1H5B1JAJX7xfxOW8b4kgEs3C2eFphWuJQ';
var file2 = UrlFetchApp.fetch(url2); // get feed
var csv2 = file2.getBlob().getDataAsString();
var csvData2 = CSVToArray(csv2); // see below for CSVToArray function
var sheet2 = ss2.getSheetByName('playerData'); //Replace this with the sheetname you want the data to appear in
for (var i2 = 0, lenCsv2 = csvData2.length; i2 < lenCsv2; i2++) {
sheet2.getRange(i2 + 1, 1, 1, csvData2[i2].length).setValues(new Array(csvData2[i2]));
}
发布于 2021-03-30 19:27:53
尝试使用{muteHttpExceptions: true}
function myFunction() {
var ss2 = SpreadsheetApp.getActive();
var url2 = 'https://drive.google.com/uc?export=download&id=1H5B1JAJX7xfxOW8b4kgEs3C2eFphWuJQ';
var file2 = UrlFetchApp.fetch(url2, {muteHttpExceptions: true });
var csv2 = file2.getBlob().getDataAsString();
console.log(csv2)
}
它起作用了!
https://stackoverflow.com/questions/66869129
复制相似问题