Running a small business or freelancing without automation is leaving money on the table. Here are 12 Python scripts I use daily — and you can get them all in one toolkit.
Why I Built These
After years of freelancing, I noticed I was spending 3+ hours daily on repetitive tasks:
- Sending invoice reminders manually
- Checking competitor prices every morning
- Backing up databases (when I remembered)
- Scraping leads one-by-one
So I automated all of it. Here's what I built:
Script 1: Web Scraper (web_scraper.py)
Universal scraper with rate limiting and retry logic:
import requests
from bs4 import BeautifulSoup
import time
def scrape_page(url, delay=1.5):
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
for attempt in range(3):
try:
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
time.sleep(delay) # Be respectful
return soup
except requests.RequestException as e:
if attempt == 2:
raise
time.sleep(delay * 2)
# Usage
soup = scrape_page('https://example.com/products')
prices = [el.text for el in soup.select('.price')]
Script 2: Email Automation (email_automation.py)
Bulk personalized emails via SMTP (works with Gmail, Zoho, any SMTP):
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import csv
def send_bulk_emails(template, contacts_csv, smtp_config):
with open(contacts_csv) as f:
contacts = list(csv.DictReader(f))
with smtplib.SMTP_SSL(smtp_config['host'], 465) as server:
server.login(smtp_config['user'], smtp_config['password'])
for contact in contacts:
msg = MIMEMultipart('alternative')
msg['Subject'] = template['subject'].format(**contact)
msg['From'] = smtp_config['user']
msg['To'] = contact['email']
body = template['body'].format(**contact)
msg.attach(MIMEText(body, 'html'))
server.send_message(msg)
print(f"Sent to {contact['email']}")
Script 3: Invoice Generator (invoice_generator.py)
Professional HTML invoices from JSON config, with PDF export:
def generate_invoice(invoice_data):
template = """
<html>
<body style="font-family: Arial, sans-serif; max-width: 800px; margin: auto;">
<h1>INVOICE #{invoice_number}</h1>
<p><strong>From:</strong> {from_name}<br>{from_address}</p>
<p><strong>To:</strong> {client_name}<br>{client_address}</p>
<table border="1" style="width: 100%">
<tr><th>Description</th><th>Amount</th></tr>
{line_items}
</table>
<p><strong>TOTAL: ${total}</strong></p>
</body>
</html>
"""
line_items = "\n".join(
f"<tr><td>{item['desc']}</td><td>${item['amount']}</td></tr>"
for item in invoice_data['items']
)
total = sum(item['amount'] for item in invoice_data['items'])
html = template.format(**invoice_data, line_items=line_items, total=total)
return html
Script 4: Price Tracker (price_tracker.py)
Monitor competitor prices and get alerts when they change:
import sqlite3
from datetime import datetime
def track_price(url, selector, db_path='prices.db'):
# Scrape current price
soup = scrape_page(url)
price_text = soup.select_one(selector).text
price = float(re.sub(r'[^\d.]', '', price_text))
# Store in SQLite
conn = sqlite3.connect(db_path)
conn.execute("""
CREATE TABLE IF NOT EXISTS prices
(url TEXT, price REAL, timestamp TEXT)
""")
conn.execute(
"INSERT INTO prices VALUES (?, ?, ?)",
(url, price, datetime.now().isoformat())
)
conn.commit()
# Check for significant changes (>5%)
prev = conn.execute(
"SELECT price FROM prices WHERE url=? ORDER BY timestamp DESC LIMIT 2",
(url,)
).fetchall()
if len(prev) > 1 and abs(prev[0][0] - prev[1][0]) / prev[1][0] > 0.05:
send_alert(f"Price changed: {url} now ${price}")
return price
Script 5: Database Backup (database_backup.py)
Automated SQLite/PostgreSQL backup with compression and S3 upload:
import subprocess
import gzip
import boto3
from datetime import datetime
def backup_database(db_config, s3_bucket=None):
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
backup_file = f"backup_{timestamp}.sql.gz"
if db_config['type'] == 'sqlite':
with open(db_config['path'], 'rb') as f_in:
with gzip.open(backup_file, 'wb') as f_out:
f_out.write(f_in.read())
elif db_config['type'] == 'postgresql':
result = subprocess.run([
'pg_dump', db_config['database']
], capture_output=True)
with gzip.open(backup_file, 'wb') as f_out:
f_out.write(result.stdout)
# Upload to S3 if configured
if s3_bucket:
s3 = boto3.client('s3')
s3.upload_file(backup_file, s3_bucket, f"backups/{backup_file}")
print(f"Backed up to s3://{s3_bucket}/backups/{backup_file}")
return backup_file
Script 6: API Monitor (api_monitor.py)
Watch your API endpoints and alert on downtime:
import requests
import time
def monitor_endpoints(endpoints, check_interval=60):
while True:
for endpoint in endpoints:
try:
start = time.time()
resp = requests.get(endpoint['url'], timeout=5)
latency = (time.time() - start) * 1000
if resp.status_code != endpoint.get('expected_status', 200):
send_alert(f"❌ {endpoint['name']} returned {resp.status_code}")
elif latency > endpoint.get('max_latency_ms', 2000):
send_alert(f"⚠️ {endpoint['name']} slow: {latency:.0f}ms")
else:
print(f"✅ {endpoint['name']}: {resp.status_code} ({latency:.0f}ms)")
except Exception as e:
send_alert(f"💥 {endpoint['name']} DOWN: {e}")
time.sleep(check_interval)
Script 7-12: More Automation
The toolkit also includes:
- Social Media Scheduler — Queue tweets/posts, auto-post at optimal times
- Lead Scraper — Extract B2B contacts from public directories
- Slack/Discord Notifier — Send formatted alerts to your team channels
- CSV to Database Importer — Auto-detect schema, bulk import CSV/Excel
- Data Cleaner — Normalize inconsistent data (dates, phone numbers, addresses)
- Report Generator — Auto-generate HTML dashboards from your data
Get All 12 Scripts
The complete toolkit (all scripts + README with setup instructions) is available for download:
👉 Python Business Automation Toolkit — $29
Each script is:
- Production-ready with error handling
- Documented with usage examples
- Easy to customize for your use case
What automation saves you the most time? Let me know in the comments — I might add it to the next version.
Top comments (0)