如何在Google Apps脚本的抓取中使用ungzip?

问题描述

我正在尝试在Google脚本中获取较大的JSON,但是由于它遇到了50Mb maximum fetch response size,因此最终被截断了。 因此,我现在尝试对其进行压缩,因为在我的浏览器中,该请求仅占用12Mb,但找不到任何使之工作的方法,知道吗?

var response = UrlFetchApp.fetch(URL,{
    method: "GET",headers: {
      'accept-encoding': 'gzip',"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/84.0.4147.125 Safari/537.36"
    }
});

var body = response.getContentText();           // Return the full JSON,should have been compressed
console.log(body.length);                       // Return 50Mb
console.log(body.substring(body.length-50));    // Can confirm it's truncated and not encoded

var res = Utilities.ungzip(response.getBlob()); // Error Invalid argument

我没有得到压缩的响应,而在最后一行得到了Error Invalid argument

我尝试了其他方法,但仍然无法获得压缩的响应。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...