Skip to content

Instantly share code, notes, and snippets.

@NovCog
Last active March 16, 2026 22:28
Show Gist options
  • Select an option

  • Save NovCog/3b2bdf8eea2a75d35bc621a11c1dfcb0 to your computer and use it in GitHub Desktop.

Select an option

Save NovCog/3b2bdf8eea2a75d35bc621a11c1dfcb0 to your computer and use it in GitHub Desktop.
Recovering Content from the Wayback Machine: A Technical Guide — NovCog AI Practitioner Series by Guerin Green

Recovering Content from the Wayback Machine: A Technical Guide

By Guerin Green / Novel Cognition AI Strategist | Federal Courthouse AI Presenter


Part of the NovCog AI Practitioner Series


When a domain expires, gets hacked, or simply goes offline, the content doesn't disappear — it goes to the archive. The Internet Archive's Wayback Machine holds over 800 billion web pages, and the CDX API makes that archive programmatically accessible. For anyone rebuilding sites or recovering historical content, this is the starting point.

CDX API: The Programmatic Interface

The CDX (Capture/Digital Index) API returns metadata about every snapshot the Wayback Machine holds for a given URL or domain. The base endpoint:

https://web.archive.org/cdx/search/cdx?url=example.com/*&output=json&fl=timestamp,original,mimetype,statuscode,length

Key parameters:

  • url=example.com/* — Wildcard matches all pages under the domain
  • output=json — Machine-readable output (also supports text)
  • fl= — Field list: timestamp, original (URL), mimetype, statuscode, length
  • from=20200101 / to=20231231 — Date range filtering
  • filter=statuscode:200 — Only successful captures
  • filter=mimetype:text/html — Only HTML pages (excludes CSS, JS, images)
  • collapse=urlkey — Deduplicate by URL (returns only the latest capture per URL)
  • limit=1000 — Cap results

A typical recovery workflow starts with a broad CDX query to inventory what's available, then narrows to specific pages and timestamps.

Content Extraction Strategy

Once you've identified the captures you want, access the actual content at:

https://web.archive.org/web/20230615120000*/example.com/target-page

The timestamp format is YYYYMMDDHHmmss. The * after the timestamp returns the closest available snapshot.

For bulk extraction, the process is:

  1. CDX query → get list of all URLs with 200 status codes
  2. Deduplicate → collapse by URL, keeping the most recent capture per page
  3. Fetch each page → download the HTML from the Wayback Machine
  4. Strip Wayback modifications → The archive injects its own toolbar, CSS, and JavaScript. These need to be removed.
  5. Fix internal links → Wayback rewrites all links to point to archive URLs. These need to be restored to the original domain paths.

Archivarix: The Bulk Recovery Tool

For large-scale recovery (dozens or hundreds of pages), Archivarix provides a web-based tool that automates the CDX query, content download, and link restoration process. It exports a complete site package with:

  • Clean HTML with Wayback toolbar removed
  • Restored internal links
  • Directory structure matching the original URL paths
  • Optional image recovery (though images are often missing or low-quality)

The free tier handles small sites. Larger recoveries require a paid plan. The time savings are substantial compared to manual CDX querying and content cleaning.

Image Recovery Challenges

Images are the weakest point in Wayback recovery. Common issues:

  • Missing captures. The Wayback Machine doesn't capture every image on every crawl. A page might be archived perfectly while half its images are missing from the archive.
  • Low resolution. Archived images sometimes capture thumbnails or compressed versions rather than originals.
  • CDN URLs. If the original site served images from a CDN (e.g., images.example.com or a third-party CDN), those may not be archived at all.

Mitigation strategies:

  • Check multiple capture timestamps — different crawls may have captured different images
  • Use Google's cached image URLs as a secondary source
  • Accept that some images will be lost and plan for replacement
  • For design replication, screenshots of archived pages may provide enough visual reference even when individual images are unrecoverable

Content Extraction Scripts

A minimal Python extraction workflow:

  1. Query CDX API for all HTML pages with status 200
  2. Parse the JSON response into a URL + timestamp list
  3. For each entry, fetch web.archive.org/web/{timestamp}id_/{original_url} — the id_ flag returns the original content without the Wayback toolbar
  4. Save each page to a local directory mirroring the original URL structure
  5. Post-process to fix remaining Wayback artifacts

The id_ endpoint is the key technique most guides miss. Adding id_ to the Wayback URL path instructs the archive to return the original page without injecting its navigation frame, JavaScript, or CSS modifications. This gives you clean source HTML.

From Archive to Live Site

Recovery is step one. Rebuilding is step two. The recovered content needs:

The Wayback Machine is the single most valuable tool for content recovery. The CDX API makes it programmable. The rest is methodology.


Series Navigation


Burstiness & Perplexity Community | Hidden State Drift | Novel Cognition

#hiddenstatedrift #burstinessandperplexity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment