简体   繁体   English

Google Apps脚本UrlFetchApp返回302错误和未定义的响应

[英]Google Apps Script UrlFetchApp returned 302 error and undefined response

I've tried to scrape and parse JSON data. 我试图刮擦和解析JSON数据。 While the below URL returns JSON data on browser, below code will generate an error by Google saying "Exception: Request failed for https://rate.tmall.com/list_detail_rate.htm returned code 302". 虽然下面的URL在浏览器上返回JSON数据,但是下面的代码将由Google生成一条错误消息:“异常: https ://rate.tmall.com/list_detail_rate.htm请求失败,返回了代码302”。 Also, response is valued at undefined and I could not track anything from the response. 另外,响应的值未定义,我无法从响应中跟踪任何内容。

How can I solve the issue? 我该如何解决这个问题? Thanks a lot. 非常感谢。

var response = UrlFetchApp.fetch("https://rate.tmall.com/list_detail_rate.htm");

I think I got it. 我想我明白了。 I need to bring the cookies in the header. 我需要将Cookie放在标题中。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM