-
-
Save twotix/5483941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function checkURLs() { | |
| var errors = []; | |
| var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
| var rows = ss.getDataRange().getValues(); | |
| for (i in rows) { | |
| var url = rows[i][0]; | |
| try { | |
| UrlFetchApp.fetch(url); | |
| } catch (e) { | |
| // This error message parsing is gross, but it looks like | |
| // http://productforums.google.com/forum/#!topic/apps-script/m_HOPHx64X8 | |
| // won't be fixed any time soon. | |
| var parsedError = e.message.match(/returned code (\d+)\. Server response/)[1]; | |
| errors.push(parsedError + ' - '+ url); | |
| } | |
| } | |
| if (errors.length) { | |
| var emailTo = Session.getActiveUser().getEmail(); | |
| MailApp.sendEmail(emailTo, 'Sitemonitor Status', errors.join('\n')); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment