SHARE
TWEET

404 Check

scaryuncledevin Aug 8th, 2014 242 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //The URL you are checking for published status
  2. var url = URL;
  3.  
  4. //The email you want to notify
  5. var email = EMAIL;
  6.  
  7. function checkForPublish() {
  8.   var scriptProperties = PropertiesService.getScriptProperties();
  9.  
  10.   if (scriptProperties.getProperty('PUBLISHED') == 'true') {
  11.     Logger.log('ALREADY PUBLISHED');
  12.     return;
  13.   }
  14.  
  15.   var result=UrlFetchApp.fetch(url,{muteHttpExceptions: true});
  16.   if (result.getResponseCode() == 200) {
  17.     Logger.log('PUBLISHED');
  18.     scriptProperties.setProperty('PUBLISHED', 'true');
  19.     MailApp.sendEmail(email, "It's alive!", "The URL " + url + " has been published!");
  20.   } else {
  21.     Logger.log('NOT PUBLISHED');
  22.   }
  23. }
RAW Paste Data
Top