google-sheets - 在 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 请求输出的示例?谢谢大家!
解决方案
当您向链接发出 GET 请求时,我对您的问题的看法是,响应以字符串形式返回。为了能够使用数据,您应该JSON.parse(fact)
使用 Use方法解析您的响应Logger.Log(JSON.parse(fact))
以查看发生了什么。
推荐阅读
- mysql - MySQL 报告:文档 #1064 - 规则 3 中与 "" 一起使用的语法有问题
- javascript - 如何使用图像制作自定义复选框?
- ssis - 如何在 Visual Studio 2019 中编辑 SSIS 脚本任务?
- sql - 在 date_trunc 之后从输出中修剪尾随 :00
- sql-server -
作业名 作业失败。作业由用户调用 . 运行的最后一步是第 1 步( ) - c# - 如何转换 Linq 表达式
> 到表达式 > - php - 使用 PHPMailer 时在电子邮件主题中获取垃圾字符。如何解决这个问题?
- python - 使用组合委托对 QTableView 进行排序会删除 delgetes,除非在双击之后
- java - 无法使用 selenium java 在 salesforce 查找窗口上找到元素
- javascript - 重新加载引导模式内容延迟问题