Automation & scripting
CLI tools, scheduled jobs, filesystem tasks, and glue scripts that save time.
Create a Python Script That Detects Website Technology Stack Automatically
This script sends an HTTP request to a URL and inspects headers and HTML content to identify technologies like servers, frameworks, and JavaScript libraries.
import requests
from re import search
def detect_tech_stack(url):
tech_stack = []
try:
response = requests.get(url, timeout=5, headers={'User-Agent': 'Mozilla/5.0'})
headers = response.headers
html = response.text.lower() if response.text else ''
# Check server header
…
How to Send an Email with smtplib and a Mock Server in Python
Send an email using smtplib and verify it with a local aiosmtpd mock SMTP server — perfect for testing without a real mail server.
import smtplib
from email.message import EmailMessage
import aiosmtpd.controller as controller
import threading
def handle_message(server, session, envelope):
print(f"Mock server received message:")
print(f"From: {envelope.mail_from}")
print(f"To: {envelope.rcpt_tos}")
print(f"Subject: {envelope.cont…
Browse by section
Each section groups closely related Python snippets.
Automation & scripting — Python code examples
What you will find here
This page collects automation & scripting snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.
Samples vs tutorials and challenges
Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.