I’m using google app script to monitoring URL is working then writing log in excel after every 30 mins:
try {
var options = {
"method" : "GET",
'headers': {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36'
},
'muteHttpExceptions': true
};
var url_trimmed = url.trim();
var response = UrlFetchApp.fetch(url_trimmed, options);
Logger.log(response.getContentText());
var result = response.getResponseCode();
return result;
}
catch (err) {
return [EXCEPT_ERR_CD, Utilities.formatString('statusCode: %s、Error: %s)', EXCEPT_ERR_CD, err)];
}
}
But when I check Excel result file, result sometimes return responseCode 200, and sometimes return 403. Immediately when responseCode returns 403, I check it in browser but site is working fine.
I tried add header
parameter but it doesn’t work.
I dont have any idea, I think maybe the error from the site but dont really know causes and how to fix it.
Thank you very much.