Check security headers for a list of websites in Python: HSTS, CSP, X-Frame-Options and an A-F grade (2026)
Security headers are the cheapest hardening a website can get: a handful of response headers that tell the browser to stay on HTTPS, refuse to run injected scripts, refuse to be framed by another site and stop guessing content types. They're also easy to forget, and they quietly disappear when someone swaps a CDN, a load balancer or a framework. Checking one site by hand is fine ( curl -sI…
Security headers are essential for securing a website, providing a few response headers that instruct the browser to maintain HTTPS, prevent injected scripts, refrain from framing other sites, and stop guessing content types. These headers can easily be overlooked and vanish when a CDN, load balancer, or framework is changed. Checking a single site manually is feasible, but reviewing an entire client list, including all subdomains or numerous prospects, becomes challenging.
This script addresses this issue by accepting a list of URLs and providing a comprehensive report for each one, including the final URL after redirects, an A-F grade, a 0-100 score, and a plain-English description of any missing security features. The script investigates several headers, such as Strict-Transport-Security (HSTS), Content-Security-Policy (CSP), X-Frame-Options, X-Content-Type-Options, Referrer-Policy, and Permissions-Policy, and assigns a score based on their presence and configuration.
A final score of 90 or higher indicates an A grade, 75 or higher a B grade, 60 or higher a C grade, 45 or higher a D grade, and anything below an F grade.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.