เขียนโค๊ดตามนี้
function check_website(url) {
var response = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
return response.getResponseCode();
}
function doLog(timestamp, responseCode, timeDiff) {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=SpreadsheetApp.setActiveSheet(ss.getSheetByName("Log"));
sheet.appendRow([timestamp, responseCode, timeDiff]);
}
function getTime() {
var startTime = new Date() ;
var responseCode=check_website("http://www.psu.ac.th");
var endTime = new Date() ;
var timeDiff = endTime-startTime;
doLog(Utilities.formatDate(new Date(), "GMT+7", "yyyyMMdd-HHmmss") , responseCode , timeDiff);
}
Comments are closed.