如何解决如何在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 举报,一经查实,本站将立刻删除。