I created a function that prints the contents of a web page based on certain keywords and also based on the date. What i wanted is to receive that output by email, but i just can't seem to find a way to do it. I also haven't found an answer for this. I'm sorry if it already exists, but i did spend a few hours looking for it and found nothing. There doesn't seem to be that much on this topic other than "how to send a mail".
def content():
for d3 in d1:
if (x or y or k or w or f) and date in d3.text.upper().lower():
print(d3.text)
print(d3.attrs['href'])
As i said, this works just fine and prints what i wanna see. The problem is that i wanna receive it by mail. I've also created mail function to send email:
def send_mail():
sender_mail="*****@gmail.com"
receiver_mail="*****@gmail.com"
password="*******"
message="hey"
server= smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(sender_mail,password)
print("login success")
server.sendmail(sender_mail, receiver_mail, message)
print("email sent")
As it is, this also works perfectly fine. It does send me an email. But i don't want a text message, i want the output of my function. I've tried to put the previous function in there, but it doesn't work.
Is there a way to do this?