-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (26 loc) · 1.07 KB
/
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
27
28
29
30
31
32
33
34
35
import datetime
import yagmail
from decouple import config
import pandas as pd
from news import NewsFeed
import time
def send_email():
today = datetime.datetime.now().strftime('%Y-%m-%d')
yesterday = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
# initialize news feed for each user
news_feed = NewsFeed(interest=row['interest'],
from_date=yesterday,
to_date=today)
email = yagmail.SMTP(user=userID, password=password)
email.send(to=row['email'],
subject=f"Your {row['interest']} news for today!",
contents=f"Hi, {row['name']}\n See what's on about {row['interest']} today. \n"
f"{news_feed.get()} \n Yagmur")
while True:
if datetime.datetime.now().hour == 8 and datetime.datetime.now().minute == 00:
df = pd.read_excel('peoples.xlsx')
userID = config('userID', default='')
password = config('password', default='')
for index, row in df.iterrows():
send_email()
time.sleep(60)