You need what a website looked like in 2019, or you need every archived page of a domain that has since gone offline. The Wayback Machine has the pages, but its web UI shows one capture at a time. This post shows a repeatable way to go from a domain name to a folder of HTML files.
The approach has two steps:
- List the captures (which URLs, which dates, which content).
- Download the original bytes of the ones you care about, slowly and politely.
Disclosure: I built the Actor used in step 1 (Wayback Machine Scraper on Apify) and it is a paid pay-per-result tool. Step 1 can also be done for free with the CDX API shown below, and step 2 is plain Python.
Step 1, free option: the CDX API
The Internet Archive exposes an index of all captures at the CDX endpoint:
curl "https://web.archive.org/cdx/search/cdx?url=example.com&matchType=domain&output=json&filter=statuscode:200&filter=mimetype:text/html&collapse=digest&from=2019&to=2021" -
matchType=domainincludes subdomains. -
collapse=digestdrops a capture when the previous one has identical content. This is the single most useful flag for bulk downloads, because most crawls re-capture unchanged pages. - The first row is a header; each following row is
urlkey, timestamp, original, mimetype, statuscode, digest, length.
That is enough for a one-off. It gets tedious when you need paging (showResumeKey), retries on HTTP 429, or the same job for 50 domains. That is the part I wrapped in an Actor.
Step 1, with the Actor
The Actor calls the same official CDX API, handles resume keys and rate limits, and returns one dataset row per capture. A row looks like this (real output, 30 Nov 2026, apify.com):
{ "originalUrl": "http://www.apify.com:80/", "timestamp": "20070531101538", "capturedAt": "2007-05-31T10:15:38Z", "snapshotUrl": "https://web.archive.org/web/20070531101538/http://www.apify.com:80/", "rawContentUrl": "https://web.archive.org/web/20070531101538id_/http://www.apify.com:80/", "mimeType": "text/html", "statusCode": 200, "digest": "EE6FCHP3MKBC3EV5D5Q4WQJNZNVUTNU6", "lengthBytes": 1013 } rawContentUrl is the useful field for archiving: the id_ flag makes the Wayback Machine return the original bytes without its toolbar and rewritten links.
Run it from the command line (get your token under Settings → Integrations in the Apify Console):
curl -X POST "https://api.apify.com/v2/acts/andreaajohansen~internet-archive-wayback/run-sync-get-dataset-items" \ -H "Authorization: Bearer $APIFY_TOKEN" \ -H "Content-Type: application/json" \ -d '{"mode":"wayback","urls":["example.com"],"matchType":"domain","from":"2019","to":"2021","collapse":"digest","mimeType":"text/html","maxItems":500}' \ > captures.json Pricing is $0.01 per run plus $1 per 1,000 rows, so the 500-row job above costs at most about $0.51.
Step 2: download the files
The Actor only returns links; it does not download archived content. This script lists the captures through the Apify client and then fetches each rawContentUrl itself:
"""Download the raw HTML of Wayback Machine snapshots listed by the Apify Actor. Usage: APIFY_TOKEN=... python download_snapshots.py example.com 2019 2021 """ import os, re, sys, time, pathlib, requests from apify_client import ApifyClient domain, year_from, year_to = sys.argv[1], sys.argv[2], sys.argv[3] out = pathlib.Path("snapshots") / domain out.mkdir(parents=True, exist_ok=True) client = ApifyClient(os.environ["APIFY_TOKEN"]) run = client.actor("andreaajohansen/internet-archive-wayback").call(run_input={ "mode": "wayback", "urls": [domain], "matchType": "domain", # the domain and all subdomains "from": year_from, "to": year_to, "collapse": "digest", # skip captures whose content did not change "onlySuccessful": True, # HTTP 200 only "mimeType": "text/html", "maxItems": 500, }) session = requests.Session() session.headers["User-Agent"] = "my-archive-project (me@example.com)" for item in client.dataset(run["defaultDatasetId"]).iterate_items(): name = re.sub(r"[^A-Za-z0-9]+", "_", item["originalUrl"])[:80] path = out / f"{item['timestamp']}_{name}.html" if path.exists(): continue r = session.get(item["rawContentUrl"], timeout=60) # original bytes, no Wayback toolbar if r.status_code == 429: # slow down and retry once time.sleep(60) r = session.get(item["rawContentUrl"], timeout=60) if r.ok: path.write_bytes(r.content) print("saved", path) time.sleep(2) # be polite to archive.org Install with pip install apify-client requests. Notes:
- Be gentle. The Internet Archive is a nonprofit running on donations. One request every two seconds is plenty, and the script backs off on HTTP 429. Consider donating if you use it a lot.
- Resumable. Files that already exist are skipped, so you can rerun after an interruption.
- Filenames combine the timestamp and the original URL, so
20190304121500_https_example_com_pricing.htmlsorts chronologically. - To fetch PDFs or images instead, change
mimeType(it accepts regular expressions, for exampleapplication/pdf) and the file extension.
Narrowing the list before you download
| Goal | Input |
|---|---|
| One page only | "matchType": "exact" with the full URL |
| A folder such as a blog | "urls": ["example.com/blog/"], "matchType": "prefix" |
| One capture per month | "collapse": "month" |
| Only changed content | "collapse": "digest" |
| First and last capture of 100 domains | "waybackOutput": "summary" |
Legal and practical notes
Archived pages are still someone else's content. Use them for research, evidence, migration of your own old site, or SEO analysis, and respect the original publisher's copyright if you republish anything. Also remember that site owners can have captures excluded, so a domain can have gaps.
Summary
CDX gives you the index, collapse=digest removes the duplicates, and rawContentUrl gives you clean original bytes. If you only do this once, use the free curl call above. If you run it regularly across many domains, the Actor saves you the paging and retry code.
Questions or a missing option? Leave a comment and I will reply.

