Advertisement
okephone

cronjob1

Jul 12th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. function cronExecute() { var url = "http://www.domaninMU.com/komen.php"; var options = { "method" : "get", "headers" : {'User-Agent' : 'Mozilla Firefox 14.0', 'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' }, "payload" : "", "contentType" : "application/xml; charset=utf-8" }; var request_starttime = new Date(); // fetch the HTTP / HTTPS request and get the response var response = UrlFetchApp.fetch(url,options); var request_endtime = new Date(); // use any spreadsheet, use its key // var ss = SpreadsheetApp.openById("KEY-SHEET"); // use this script's default spreadsheet var ss = SpreadsheetApp.getActiveSpreadsheet(); // get the worksheet var sheet = ss.getSheets()[0]; // inserting values into the sheet sheet.insertRowBefore(1); var colValues = [[ request_starttime, request_endtime, response.getResponseCode(), response.getHeaders().toSource(), url, response.getContentText() ]]; sheet.getRange(1, 1, 1, 6).setValues(colValues); // if something is not working, use the Logger object/function (uncomment it and modify it) // Logger.log(ss.getSpreadsheetTimeZone()); // view the log details from VIEW -> LOGS // You can also RUN the script and view its Execution log // try this VIEW -> EXECUTION TRANSCRIPTS // Make sure you MODIFY and then RUN the script and // verify its working OK by looking at the spreadsheet contents // try this RUN -> CRONEXECUTE // check the spreadsheet contents // After its working OK, you should setup a TRIGGER to execute it as and when you want (frequency) // try this TRIGGERS -> ALL YOUR TRIGGERS }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement