Python Automation Projects That Actually Save Time

We all have better things to do than manually creating passwords or copying text from PDFs. Here are five real-world Python automations I use regularly that might just change how you work.

1. The Password Generator You’ll Actually Use

Forget “password123” – here’s how to create secure passwords programmatically:

python

Copy

Download

import secrets

import string

def create_password(length=12, include_special=True):

“””Generate a cryptographically strong password”””

chars = string.ascii_letters + string.digits

if include_special:

chars += string.punctuation

while True:

pwd = ”.join(secrets.choice(chars) for _ in range(length))

# Ensure it meets basic complexity requirements

if (any(c.islower() for c in pwd)

and any(c.isupper() for c in pwd)

and (not include_special or any(c in string.punctuation for c in pwd))):

return pwd

print(f”Your new password: {create_password()}”)

Why this rocks:

  • Uses Python’s secrets module (safer than random)
  • Guarantees mixed case and special characters
  • No more password reuse across sites

2. Email Automation That Doesn’t Land in Spam

Sending batch emails without getting flagged is tricky. Here’s what works:

python

Copy

Download

import smtplib

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart

def send_email(to_addr, subject, body):

msg = MIMEMultipart()

msg[‘From’] = ‘[email protected]

msg[‘To’] = to_addr

msg[‘Subject’] = subject

msg.attach(MIMEText(body, ‘plain’))

with smtplib.SMTP(‘smtp.gmail.com’, 587) as server:

server.starttls()

server.login(‘[email protected]’, ‘your_app_password’) # Use app password

server.send_message(msg)

print(f”Email sent to {to_addr}”)

# Usage

send_email(

to_addr=”[email protected]”,

subject=”Meeting Reminder”,

body=”Just confirming our 2pm call tomorrow”

)

Pro tips:

  • Create an “App Password” in Gmail settings
  • Add delays between sends (5-10 seconds)
  • Always use TLS encryption

3. PDF Text Extraction That Doesn’t Suck

Extracting text from PDFs is notoriously messy. This approach handles most cases:

python

Copy

Download

import PyPDF2

import textract # pip install textract

def pdf_to_text(filename):

text = “”

with open(filename, ‘rb’) as f:

pdf = PyPDF2.PdfReader(f)

for page in pdf.pages:

text += page.extract_text() + “\n”

# Fallback for image-based PDFs

if len(text.strip()) < 50:

text = textract.process(filename).decode(‘utf-8’)

return text

# Save to file

with open(‘extracted.txt’, ‘w’) as f:

f.write(pdf_to_text(‘contract.pdf’))

Handles:

  • Regular PDFs
  • Scanned documents (requires OCR)
  • Preserves basic formatting

4. News Monitoring Script

Stay updated without visiting 20 news sites:

python

Copy

Download

from newspaper import Article

import pandas as pd

def scrape_news(urls):

articles = []

for url in urls:

article = Article(url)

article.download()

article.parse()

articles.append({

‘title’: article.title,

‘source’: url,

‘summary’: article.summary,

‘published’: article.publish_date

})

return pd.DataFrame(articles)

# Track competitors

df = scrape_news([

‘https://techcrunch.com/startups/’,

‘https://www.theverge.com/tech’

])

df.to_csv(‘tech_news.csv’, index=False)

5. WhatsApp Automation That Works (Mostly)

Warning: WhatsApp doesn’t officially support this. Use responsibly.

python

Copy

Download

from selenium import webdriver

from selenium.webdriver.common.by import By

import time

def whatsapp_msg(contact_name, message):

driver = webdriver.Chrome()

driver.get(“https://web.whatsapp.com”)

# Wait for manual QR scan

input(“Scan QR code then press Enter…”)

time.sleep(5) # Let page load

try:

# Find contact

contact = driver.find_element(

By.XPATH, f”//span[@title='{contact_name}’]”

)

contact.click()

# Type message

msg_box = driver.find_element(

By.XPATH, “//div[@contenteditable=’true’]”

)

msg_box.send_keys(message)

msg_box.send_keys(Keys.RETURN)

print(“Message sent!”)

except Exception as e:

print(f”Failed: {str(e)}”)

finally:

driver.quit()

whatsapp_msg(“Mom”, “Running late, be home soon!”)

Important notes:

  • WhatsApp may temporarily ban accounts using automation
  • Never spam or send bulk messages
  • This is for personal convenience only

Final Thoughts

The best automations solve real pain points without creating new problems. Start small with one of these scripts, tweak it to your needs, and watch your productivity soar.

Remember: With great automation power comes great responsibility. Don’t be that person who gets their IP banned because they scraped too aggressively.

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *