Sitemap
Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

Follow publication

20 Python scripts to automate common daily tasks

4 min readNov 11, 2024

--

Press enter or click to view image in full size
Photo by Hitesh Choudhary on Unsplash

Here are 20 Python scripts to automate common daily tasks, with explanations and examples for each:

1. Email Notifications

Automate sending daily email updates.

import smtplib
from email.message import EmailMessage

def send_email(subject, body, to_email):
msg = EmailMessage()
msg.set_content(body)
msg['Subject'] = subject
msg['From'] = 'youremail@example.com'
msg['To'] = to_email

with smtplib.SMTP('smtp.example.com', 587) as smtp:
smtp.starttls()
smtp.login('youremail@example.com', 'password')
smtp.send_message(msg)

send_email('Daily Update', 'Your daily update goes here.', 'recipient@example.com')

2. Web Scraping for News Headlines

Automatically fetches the latest news headlines from a website.

import requests
from bs4 import BeautifulSoup

def get_news():
url = 'https://news.ycombinator.com/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
headlines = [item.text for item in soup.select('.storylink')[:5]]
return headlines

print(get_news())

3. Download Stock Prices

--

--

Python in Plain English
Python in Plain English

Published in Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

No responses yet