Back to KB
Difficulty
Intermediate
Read Time
5 min

Audit Every Page on Your Site from sitemap.xml in One Command

By Codcompass TeamΒ·Β·5 min read

"Audit my site" almost never means one URL. It means the homepage, the pricing page, the top twenty blog posts, every product, every category, every location page. On any real site that's hundreds to thousands of URLs, and clicking each one through a free checker is not a workflow β€” it's a way to lose an afternoon.

This post walks through the workflow we recommend instead: pull your sitemap.xml, hand the URL list to the batch audit endpoint, and export a single CSV ranked by priority. It's ~40 lines of Python. It works on any site that publishes a sitemap. And the size of your site tells you which plan tier to start on.

The whole script

import csv
import os
import xml.etree.ElementTree as ET
import requests

API_KEY = os.environ["SEOSCORE_API_KEY"]
SITEMAP_URL = "https://example.com/sitemap.xml"
BASE = "https://api.seoscoreapi.com"

# 1. Fetch the sitemap
xml = requests.get(SITEMAP_URL, timeout=20).text
ns = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}
root = ET.fromstring(xml)
urls = [loc.text for loc in root.findall(".//sm:url/sm:loc", ns)]

print(f"Found {len(urls)} URLs in sitemap")

# 2. Batch audit (chunked at 50 to stay under per-call limits)
rows = []
for i in range(0, len(urls), 50):
    chunk = urls[i:i + 50]
    r = requests.post(
        f"{BASE}/audit/batch",
        headers={"X-API-Key": API_KEY},
        json={"urls": chunk},
        timeout=180,
    )
    r.raise_for_status()
    for result in r.json()["results"]:
        rows.append({
            "url": result["url"],
            "score": result.get("score", 0),
            "grade": result.get("grade", "F"),
            "seo": result.get("categories", {}).get("seo", 0),
            "performance": result.get("categories", {}).get("performance", 0),
            "accessibility": result.get("categories", {}).get("accessibility", 0),
            "ai_readability": result.get("categories", {}).get("ai_readability", 0),
            "priority_issues": len(result.get("priority", [])),
   

πŸŽ‰ Mid-Year Sale β€” Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register β€” Start Free Trial

7-day free trial Β· Cancel anytime Β· 30-day money-back