问题描述
我正在尝试在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 (将#修改为@)