-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
26 lines (19 loc) · 862 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# AMS Journal website scraping and emailing script
from recipients_and_app_data import recipients
from journal_scraper import checkForUpdates
from scripts.mongo_functions import checkForNewArticles, markEmailedArticles
from scripts.render_template import renderTemplate
from scripts.emailer import sendEmail
def main():
checkForUpdates() # Check for new articles and pull to db if they exist:
if checkForNewArticles():
# loop through the recipients and render/send an email to each of them
for recipient in recipients:
print('Rendering email for ' + recipient['name'])
renderTemplate(recipient['name'])
print('Sending email to ' + recipient['email'])
sendEmail(recipient['email'])
# mark sent emails in db
markEmailedArticles()
if __name__ == '__main__':
main()