DEV Community

Data Goose
Data Goose

Posted on Edited on

Using Common Crawl S3 as a fallback when Wayback snapshots fail on AWS

If you query the Wayback Machine from an AWS container, web.archive.org/cdx/search/cdx usually works fine, while raw snapshot fetches (web.archive.org/web/{timestamp}id_/{url}) often return HTTP 500. Running residential proxies just to read public HTML snapshots adds cost and latency that doesn't make sense for lightweight lookups.

Using Common Crawl's S3 archive as a fallback avoids that issue. Its public CDX index points directly to the .warc.gz file, byte offset, and byte length for a capture. With an HTTP Range request, you only pull the few kilobytes needed for one page instead of downloading a full WARC segment.

import gzip, json, httpx

with httpx.Client(timeout=15.0) as client:
    r = client.get(
        "https://index.commoncrawl.org/CC-MAIN-2026-43-index",
        params={"url": "example.com", "output": "json", "limit": 1, "filter": "status:200"},
    )
    hit = json.loads(r.text.splitlines()[0])
    start = int(hit["offset"])
    end = start + int(hit["length"]) - 1

    warc_gz = client.get(
        f"https://data.commoncrawl.org/{hit['filename']}",
        headers={"Range": f"bytes={start}-{end}"},
    ).content
    raw_http = gzip.decompress(warc_gz).split(b"\r\n\r\n", 2)[-1]
    print(raw_http.decode("utf-8", errors="replace")[:300])
Enter fullscreen mode Exit fullscreen mode

Two small additions make this a lot more reliable in practice. First, newer indexes like CC-MAIN-2026-47 sometimes return transient 502 responses, so scanning across the 4 or 5 most recent crawls prevents needless failures. Second, extracting clean text by walking HTML block tags (p, div, li, headings, table rows) keeps line breaks intact when pages are minified, which makes line-by-line historical diffs readable.

This pattern is mainly useful for OSINT and SEO researchers tracking competitor copy changes, teams auditing old domain content, or AI agents that need archived page text from cloud environments without browser automation. If you want an already hosted REST API and MCP endpoint with Wayback CDX timelines, Common Crawl fallback, diffing, and Archive.org search wired together, it is up here: wayback-archive-intel-mcp.

Top comments (1)

Collapse
 
dosaygo profile image
DOSAYGO •

When a page loads its discussion separately, how do you tell whether either archive captured the comments alongside the article?