Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|
||
|
||
|
||
|
||
|