Last active
August 29, 2015 13:57
-
-
Save yoshimov/9363009 to your computer and use it in GitHub Desktop.
Notify specific web page periodically using GAS
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 notifyIssues() { | |
| var issueurl = PropertiesService.getScriptProperties().getProperty("issueurl"); | |
| var toaddress = PropertiesService.getScriptProperties().getProperty("mailaddress"); | |
| var httpuser = PropertiesService.getScriptProperties().getProperty("httpuser"); | |
| var httppass = PropertiesService.getScriptProperties().getProperty("httppassword"); | |
| var subject = PropertiesService.getScriptProperties().getProperty("subject"); | |
| var header = PropertiesService.getScriptProperties().getProperty("header"); | |
| var passenc = Utilities.base64Encode(httpuser + ":" + httppass); | |
| var response = UrlFetchApp.fetch(issueurl, {"headers": {"Authorization": "Basic " + passenc}}); | |
| var content = response.getContentText(); | |
| var bodyIndex = content.indexOf("wiki-body"); | |
| var listIndex = content.indexOf("<hr", bodyIndex) + 6; | |
| var bodyEnd = content.indexOf("</div>", listIndex); | |
| var listContent = content.substring(listIndex, bodyEnd).trim(); | |
| if (listContent && listContent.length > 0) { | |
| // send mail | |
| MailApp.sendEmail(toaddress, "", subject, header + listContent + "<p><a href=\"" + issueurl + "\">" + issueurl + "</a></p>"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment