【发布时间】:2023-03-30 10:29:01
【问题描述】:
我正在尝试从 webpage 获取带有适当参数的 get http 请求的 json 响应,但我得到 403 Forbidden 作为响应。当我在 python 中做同样的事情时,我会得到相应的响应。但是,当我采用以下方法时,事情就会出错:
function capterraScraper() {
var Url = 'https://www.capterra.com/directoryPage/rest/v1/category';
var params = {
'htmlName': '360-degree-feedback-software',
'rbr': 'false',
'countryCode': 'BD'
};
var options = {
'method' : 'GET',
'params' : params,
'headers' : {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'
}
};
var response = UrlFetchApp.fetch(Url, options);
console.log(JSON.parse(response));
}
如何让脚本产生 json 响应?
【问题讨论】:
-
你能展示你的python脚本吗?
-
Gite this 支票@TheMaster。
标签: google-apps-script web-scraping google-sheets parameters http-status-code-403