# Wayback Machine Scraper: Clean Markdown & Historical Page Diff (`accommodating_fuel/histdiff`) Actor

Compare two archived versions of a web page near two dates. Get a clean Markdown diff, both Wayback capture links, and CDX digests.

- **URL**: https://apify.com/accommodating_fuel/histdiff.md
- **Developed by:** [Carlo Clores](https://apify.com/accommodating_fuel) (community)
- **Categories:** Developer tools, SEO tools, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$25.00 / 1,000 valid diffs

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## histdiff

Compare a web page on two dates. Each result includes the later page as clean Markdown, a unified line diff, and both Wayback replay URLs and CDX digests. One changed, usable pair costs **$0.025**. An unchanged pair, missing capture, junk page, or failed comparison costs **$0** under the Store configuration below.

### Run in Apify Console

1. Sign in to Apify. Open the published **histdiff** Actor in the Store, or open your private build under **Actors** after deployment.
2. Open **Input** and switch to **JSON**. Paste the input below and select **Start**. Each date is a UTC calendar day. The start date can equal the end date.
3. Open the completed run's **Output** tab. **Comparisons** shows status and replay links. **Text and provenance** shows the diff, Markdown and digests. To retrieve every field, export the default dataset as JSON with all fields selected.

```json
{
  "urls": ["https://openai.com/pricing", "https://stripe.com/pricing"],
  "date_start": "2024-01-01",
  "date_end": "2026-01-01",
  "tolerance_days": 45,
  "min_words": 50
}
```

Supply 1–50 absolute HTTP(S) URLs. Each entry produces one row in input order, including duplicates. Both dates are required in YYYY-MM-DD form. The default tolerance is 45 days and accepts zero for an exact calendar day. The default minimum word count is 50 and accepts integers of one or more.

### Reading a result

This example uses fixture HTML with one changed line out of five. The timestamps and digests illustrate the shape of the archive metadata.

```json
{
  "url": "https://example.com/pricing",
  "status": "ok",
  "billable": true,
  "timestamp_a": "2024-01-01T14:22:10Z",
  "timestamp_b": "2025-12-28T09:11:04Z",
  "archive_url_a": "https://web.archive.org/web/20240101142210id_/https://example.com/pricing",
  "archive_url_b": "https://web.archive.org/web/20251228091104id_/https://example.com/pricing",
  "cdx_digest_a": "J7K2NVF5YLWWDGLKJOKHXLZPYCZ3LJXA",
  "cdx_digest_b": "KXS2G7YBQNG2S3LONDKPQ6VZ533HJJBN",
  "title_b": "Pricing - Example",
  "word_count_b": 58,
  "markdown_b": "# Pricing\n\nThe Pro plan includes support for every member of your team. All plans come with a monthly invoice and there are no setup fees. Each member has their own workspace and can invite teammates to join projects. Your administrator can change the number of seats at any time from the account settings page.\n\nPro: $49 per month.",
  "unified_diff": "--- a\n+++ b\n@@ -2,4 +2,4 @@\n \n The Pro plan includes support for every member of your team. All plans come with a monthly invoice and there are no setup fees. Each member has their own workspace and can invite teammates to join projects. Your administrator can change the number of seats at any time from the account settings page.\n \n-Pro: $29 per month.\n+Pro: $49 per month.",
  "change_ratio": 0.2,
  "error": null
}
```

`unified_diff` uses stable file labels `a` and `b`, LF separators, and three lines of context. Minus lines belong to the start capture. Plus lines belong to the end capture. The ratio is `(larger line count − matching line count) / larger line count` using the same line matcher as the diff. A replacement counts once. Blank lines participate. Equal Markdown yields `status: "ok"`, an empty diff, ratio zero and both sets of provenance.

| Status | Meaning | Charge |
| --- | --- | --- |
| `ok` | Both captures passed extraction | $0.025 for a nonempty diff, otherwise $0 |
| `no_snapshot` | CDX returned no eligible capture for a requested date | $0 |
| `junk` | Every attempted digest for a date failed the content checks | $0 |
| `error` | The input, upstream, extraction, or spending limit prevented delivery of a comparison | $0 |

Failure rows contain the URL and error code with all comparison fields set to null. Codes include `INVALID_URL`, `INVALID_INPUT`, `NO_SNAPSHOT`, `JUNK_SNAPSHOT`, `UPSTREAM_TIMEOUT`, `UPSTREAM_HTTP_ERROR`, `INVALID_CDX`, `REPLAY_MISMATCH`, `PROXY_UNAVAILABLE`, `EXTRACTION_FAILED`, `RESPONSE_TOO_LARGE`, `RESULT_TOO_LARGE` and `CHARGE_LIMIT`. A missing or invalid URL array fails input validation before any charge.

### Capture selection and junk policy

1. The Actor lowercases the host and removes the fragment and tracking keys `utm_*`, `gclid`, and `fbclid` case-insensitively. CDX receives the remaining URL, including its query.
2. For each date, it asks CDX for exact URL matches with status 200 and MIME type `text/html`, collapsing adjacent duplicate digests. It searches backward from the end of the requested UTC day first, then forward from the next midnight if needed. Both tolerance boundaries are inclusive. A same-day capture wins over all earlier captures. The reverse search keeps the most recent member of a repeated digest. [Wayback CDX documentation](https://github.com/internetarchive/wayback/tree/master/wayback-cdx-server)
3. The Actor fetches the CDX row's **original URL** via its timestamped `id_` replay. Redirects produce a free upstream error. A replay's declared content type must be HTML or XHTML, and a supplied Memento datetime must agree with the CDX timestamp. Up to three URLs run concurrently, with one Wayback request at a time per URL. All requests use Apify Proxy, a ten-second deadline per attempt, and up to two retries on transport errors, HTTP 408, 429, or 5xx.
4. The Actor checks the original HTML title and **every H1** for these case-insensitive phrases: `just a moment`, `attention required`, `access denied`, `404 not found`, `page not found`, `parked`, and `domain is for sale`. For extracted pages under 150 words it also checks body text for `verify you are human`, `verify you're human`, `checking your browser`, `enable javascript and cookies to continue`, and `performing security verification`.
5. Trafilatura extracts Markdown with links from the server-returned HTML. A missing document, empty extraction, or extraction below `min_words` is junk. The count uses Unicode word tokens in the resulting Markdown, including link text and destinations. Apostrophes and internal hyphens can join a token. Equality with the threshold passes. [Trafilatura extraction API](https://trafilatura.readthedocs.io/en/latest/corefunctions.html)
6. If the first digest is junk, the Actor tries exactly one other distinct digest when available, in the same before-then-after order. If neither passes, the row is `junk`. A replay transport failure or extractor exception produces a free error. A response over 8,000,000 decoded bytes or a result over 8,000,000 serialized bytes produces a free size error.

### Synchronous REST call

The deployed Actor's **API** tab shows its ID. In PowerShell, set `APIFY_TOKEN` to a personal token from **Console → Settings → Integrations**, then run the following. Enter the publisher's Apify username at the prompt. The response is an array of dataset rows. [Synchronous Actor endpoint](https://docs.apify.com/api/v2/actor-run-sync-get-dataset-items-post)

```powershell
$publisher = Read-Host 'Apify publisher username'
$endpoint = "https://api.apify.com/v2/actors/$publisher~histdiff/run-sync-get-dataset-items"
$body = @{
    urls = @('https://stripe.com/pricing')
    date_start = '2024-01-01'
    date_end = '2026-01-01'
} | ConvertTo-Json
$headers = @{ Authorization = "Bearer $env:APIFY_TOKEN" }
$rows = Invoke-RestMethod -Method Post -Uri $endpoint -Headers $headers -ContentType 'application/json' -Body $body -TimeoutSec 310
$rows | ConvertTo-Json -Depth 5
```

Apify's synchronous endpoint waits up to 300 seconds. For a large batch, use Console or an asynchronous Actor run. If the HTTP connection times out, check **Runs** before starting another paid comparison.

### Apify MCP

Add the hosted Streamable HTTP server `https://mcp.apify.com?tools=call-actor,get-actor-run,get-dataset-items` to your MCP client's remote servers. Connect and sign in to Apify using the browser authorization flow. Give the client the published Actor's full name and input. Substitute the publisher's username in this request. [Apify MCP setup and tools](https://docs.apify.com/mcp)

> Use call-actor to run PUBLISHER/histdiff for https://stripe.com/pricing between 2024-01-01 and 2026-01-01. Wait for completion, read the default dataset, and show the first row's status, billable flag, diff and both archive links.

The run response contains a run ID and default dataset ID. Follow the run to completion if still active, then use the storage tools to read the dataset items. REST and MCP each start a separate run.

### Project files and local verification

```text
histdiff/
  .actor/
    actor.json
    input_schema.json
    output_schema.json
    dataset_schema.json
  Dockerfile
  .actorignore
  src/
    main.py
    cdx.py
    extract.py
    diff.py
  tests/
    test_actor.py
    test_release.py
  requirements.txt
  TEST_PLAN.md
  README.md
```

From this directory with Python 3.12 installed, run these PowerShell commands. The acceptance suite uses temporary storage and simulated archive responses. The package pins the three direct dependencies.

```powershell
python -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements.txt
.\.venv\Scripts\python -m unittest discover -s tests -v
```

For a local live run, save the input example as UTF-8 `INPUT.json` in this folder, configure your Apify Proxy credentials in the environment, and run `.\.venv\Scripts\python -m src.main`. The SDK writes results to local storage. Each independent local run needs a fresh default dataset. [20-URL test plan](TEST_PLAN.md)

### Deployment checklist

- \[ ] Install the Apify CLI with `npm install -g apify-cli`. From the Actor directory, run `apify login` and sign in to the publisher account. [CLI documentation](https://docs.apify.com/cli)
- \[ ] For a new empty project, run `apify init` before copying in this source. The supplied directory already contains the initialized Actor definition. Verify the Actor name is `histdiff` and the publisher account has the intended Actor slot.
- \[ ] Run the local tests, then `apify push`. Wait for a successful build of version 0.1. Confirm Apify Proxy access on the account and run the private build once. [Actor deployment](https://docs.apify.com/actors/development/deployment)
- \[ ] In Console's monetization settings, choose **Pay per event**, add a flat-price primary event named exactly `valid-diff`, title it **Valid diff**, and set its price to **USD 0.025** across plans. Give it the description “One delivered comparison with two usable captures and a nonempty Markdown diff.”
- \[ ] Remove or zero-price both synthetic events, `apify-actor-start` and `apify-default-dataset-item`. Turn off **Pay per event + usage**. Confirm that the pricing preview has exactly one positive-priced event. These account settings establish the Store price. [Apify pay-per-event configuration](https://docs.apify.com/actors/monetize/pay-per-event)
- \[ ] Read the Store preview and publish the Actor to Apify Store. Run one synchronous REST call and one MCP call using the examples above. Inspect their datasets and compare their event ledgers with the billable results. Use equal dates on a known good capture to check that a successful unchanged comparison costs $0.

The Actor writes eligible rows before calling `Actor.charge`. A failed dataset write stops the run before billing that row. Apify storage and billing are separate operations. If the process stops in between, a delivered row can be free. A resumed run skips already written rows by input position to avoid billing them twice. The `billable` flag describes eligibility and Apify's event ledger records the actual charge.

### What I deliberately did not build

v0.1 excludes a standalone API, RapidAPI integration, custom MCP server, cache, Common Crawl, headless browser, LLM summaries, and WARC byte-offset verification. Apify handles access, proxies, storage and billing. The provenance fields identify the CDX records used for each comparison.

# Actor input Schema

## `urls` (type: `array`):

Enter 1 to 50 absolute HTTP or HTTPS page URLs.

## `date_start` (type: `string`):

Earlier comparison day in YYYY-MM-DD format.

## `date_end` (type: `string`):

Later comparison day in YYYY-MM-DD format.

## `tolerance_days` (type: `integer`):

Search this many UTC calendar days on either side of each date.

## `min_words` (type: `integer`):

Reject a capture with fewer Markdown words than this threshold.

## Actor input object example

```json
{
  "urls": [
    "https://openai.com/pricing",
    "https://stripe.com/pricing"
  ],
  "date_start": "2024-01-01",
  "date_end": "2026-01-01",
  "tolerance_days": 45,
  "min_words": 50
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://openai.com/pricing",
        "https://stripe.com/pricing"
    ],
    "date_start": "2024-01-01",
    "date_end": "2026-01-01"
};

// Run the Actor and wait for it to finish
const run = await client.actor("accommodating_fuel/histdiff").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": [
        "https://openai.com/pricing",
        "https://stripe.com/pricing",
    ],
    "date_start": "2024-01-01",
    "date_end": "2026-01-01",
}

# Run the Actor and wait for it to finish
run = client.actor("accommodating_fuel/histdiff").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://openai.com/pricing",
    "https://stripe.com/pricing"
  ],
  "date_start": "2024-01-01",
  "date_end": "2026-01-01"
}' |
apify call accommodating_fuel/histdiff --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,accommodating_fuel/histdiff"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/9i6KwmP7zoW1Cn2sK/builds/pfTww7Lq0xk92hnKT/openapi.json
