首页 > 解决方案 > 在 GoogleSheet 中使用 API

问题描述

我想从https://www.coinspeaker.com/ieo/feed/导入谷歌表格数据

function callCoinSpeaker() {
  var response = UrlFetchApp.fetch("https://www.coinspeaker.com/ieo/feed/");
  Logger.log(response.getContentText());
  var fact = response.getContentText();
  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange(1,1).setValue([fact]);
}   

该脚本工作正常,但我不知道如何格式化所有在单个单元格(A1)中的输出。

我想创建一个自动将输出格式化为列和行的代码。任何格式化 API 请求输出的示例?谢谢大家!

标签: google-sheetsgoogle-sheets-api

解决方案


当您向链接发出 GET 请求时,我对您的问题的看法是,响应以字符串形式返回。为了能够使用数据,您应该JSON.parse(fact) 使用 Use方法解析您的响应Logger.Log(JSON.parse(fact))以查看发生了什么。


推荐阅读