diff --git a/4006 Project/4006.py b/4006 Project/4006.py new file mode 100644 index 0000000..55f468d --- /dev/null +++ b/4006 Project/4006.py @@ -0,0 +1,81 @@ +import pickle +import pathlib +import smtplib, ssl +import newspaper +import datetime + +##### Scraper Module##### + +url = 'https://www.bbc.co.uk/news/technology' +paper = newspaper.build(url) +filename2 = 'PreUpdate' + abspath2 = pathlib.Path(filename).absolute() + file2 = open(abspath, 'rb') + PreUpdate = pickle.load(file2) + print(subscriber_List) + file.close() + +target = article.title +if target and len(target.strip())>0 and (article.publish_date <= datetimePreUpdate): + newUpdate = (str(target.strip().replace('\n','')) + \n + str(article.url)) + +################################ + +subscriber_List = [] +satisfied = "no" +while satisfied == "no": + Goal = input("Would you like to send out annother update[U} or manage subscribers[M]?") + +##### Subscriber Module ##### + filename = 'subs' + abspath = pathlib.Path(filename).absolute() + file = open(abspath, 'rb') + subscriber_List = pickle.load(file) + print(subscriber_List) + file.close() + + if Goal == "M": + SAD = input("Would you like to add a subscriber[A], delete a subscriber[D] or are you satisfied[S]?") + if SAD == "A": + NewUser = input("What is the email address of the new user?") + subscriber_list.append(NewUser) + file = open(abspath, 'wb'): + pickle.dump(subscriber_List, fi) + file.close() + + + elif SAD == "D": + DelUser = input("What is the email address of the user you want to delete?") + subscriber_list.remove(DelUser) + file = open(abspath, 'wb'): + pickle.dump(subscriber_List, fi) + file.close() + + else: + satisfied = "yes" + + +#### Email Module ##### + if Goal == "U": + Y = 0 + for x in subscriber_List: + port = 465 + smtp_server = "smtp.gmail.com" + sender_email = "isaacuniwork@gmail.com" + receiver_email = subscriber_List[Y] + password = "Sercet1212" + message = newUpdate + Y = Y + 1 + context = ssl.create_default_context() + with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: + server.login(sender_email, password) + server.sendmail(sender_email, receiver_email, message) + satisfied = "yes" + +print("That should be all, the program will now close") +exit() + + + + +