# Website Change Monitor — Price and Content Diff (`matakupanlabs/website-change-monitor`) Actor

Monitor any public web page for price, stock, or content changes. Runs on a schedule, stores a persistent snapshot, and reports only real differences with a diff and timestamp. Useful for competitor pricing, product availability, and policy pages. Pay per check, no browser setup.

- **URL**: https://apify.com/matakupanlabs/website-change-monitor.md
- **Developed by:** [uzi](https://apify.com/matakupanlabs) (community)
- **Categories:** Automation, Developer tools, E-commerce
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 page checkeds

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

## Website Change Monitor — Price, Stock & Content Diff Tracker

Monitor any web page and get **structured change events**: price drops and increases, restocks,
out-of-stock alerts, and exact added/removed content lines. Each run compares the live page with
the snapshot stored by the previous run — state persists across runs in a named key-value store,
so you just **schedule it daily/hourly and read the dataset**.

No browser needed — fast, cheap HTTP fetching with browser-like headers (`got-scraping`).

### What it does

1. Fetches every target URL (30s timeout, redirects followed, 2 retries on 429/5xx).
2. Extracts comparable content in `TEXT`, `HTML`, or `JSON` mode (optional `cssSelector` scoping).
3. Removes lines matching your `ignorePatterns` (timestamps, CSRF tokens, view counters) so they
   don't trigger false changes.
4. Detects **price** (JSON-LD `offers.price` → `meta[property=product:price:amount]` → microdata
   `[itemprop=price]` → currency-symbol regex) and **stock status** (JSON-LD `availability` →
   visible-text patterns like "sold out" / "add to cart").
5. Compares with the previous snapshot (hash + order-aware line diff) and pushes one record per
   target: `FIRST_RUN`, `CHANGED`, `UNCHANGED`, or `ERROR`. Errors are always reported.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `targets` | array | required | One entry per page: `url` (required), `label`, `cssSelector`, `checkPrice` (default `true`) |
| `mode` | select | `TEXT` | `TEXT` visible text · `HTML` raw markup · `JSON` pretty-printed parsed JSON (falls back to TEXT on parse failure) |
| `onlyReportChanges` | boolean | `false` | Skip `UNCHANGED` records; change events and `ERROR`s are still saved |
| `ignorePatterns` | string list | — | Regexes; any line matching one is dropped before comparison |
| `stateNamespace` | string | `default` | Isolates snapshot stores when several monitors share one Apify account |
| `maxDiffLines` | integer | `40` | Cap per side on `addedLines` / `removedLines` |
| `proxyConfiguration` | object | — | Optional Apify proxy; enable if targets rate-limit datacenter traffic |

**Tips**

- `cssSelector` scopes both comparison and price/stock detection to the first matching element —
  e.g. `div.product_main` to ignore the footer. If it stops matching (page redesign), the run
  reports `ERROR` instead of silently wiping your baseline.
- In `JSON` mode the DOM is not parsed, so price/stock detection falls back to the text regex.
- A price counts as changed at **±0.5%** or more (no alerts for rounding noise).

### Output fields (dataset)

| Field | Description |
|---|---|
| `_type` | Always `"change"` |
| `url`, `label` | The monitored target and your label |
| `status` | `FIRST_RUN` | `UNCHANGED` | `CHANGED` | `ERROR` |
| `changed` | `true` for every record that is not `UNCHANGED` |
| `changeTypes` | `PRICE_DROP`, `PRICE_INCREASE`, `RESTOCK`, `OUT_OF_STOCK`, `CONTENT_ADDED`, `CONTENT_REMOVED`, `CONTENT_CHANGED` |
| `firstSeenAt`, `previousCheckedAt`, `lastCheckedAt`, `scrapedAt` | ISO timestamps |
| `priceCurrent`, `pricePrevious`, `priceChangePct`, `currency` | Price now vs. previous run |
| `stockStatus` | `IN_STOCK` | `OUT_OF_STOCK` | `UNKNOWN` |
| `addedLines`, `removedLines` | Line-level diff, capped at `maxDiffLines` per side |
| `contentLength`, `contentHash` | Characters compared and hash of normalized content |
| `summary` | One-line human-readable summary |
| `errorMessage` | Detail when `status` is `ERROR`, else `null` |

### Example change event

```json
{
  "_type": "change",
  "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
  "label": "priced product",
  "status": "CHANGED",
  "changed": true,
  "changeTypes": ["PRICE_DROP", "RESTOCK"],
  "firstSeenAt": "2026-11-04T09:00:00.000Z",
  "previousCheckedAt": "2026-11-03T09:00:04.112Z",
  "lastCheckedAt": "2026-11-04T09:00:02.540Z",
  "priceCurrent": 47.18,
  "pricePrevious": 51.77,
  "currency": "GBP",
  "priceChangePct": -8.87,
  "stockStatus": "IN_STOCK",
  "addedLines": ["<p class=\"availability\">In stock (25 available)</p>"],
  "removedLines": ["<p class=\"availability\">In stock (19 available)</p>"],
  "contentLength": 1521,
  "contentHash": "9c3fce8a1b2d4e5f6a7b8c9d0e1f2a3b4c5d6e7f",
  "summary": "Change detected: price dropped 51.77 GBP -> 47.18 GBP; 1 line(s) added, 1 line(s) removed.",
  "errorMessage": null,
  "scrapedAt": "2026-11-04T09:00:02.540Z"
}
```

### Scheduling advice

- **Daily 1–2×**: competitor prices, landing pages, compliance pages.
- **Every 1–4 hours**: stock status and restocks on fast-moving products.
- Always on: `onlyReportChanges: true` — the dataset then contains only events, one run per day
  keeps storage small. Add `ignorePatterns` for anything volatile (counters, session IDs, dates).
- The first run stores a baseline (`FIRST_RUN`); meaningful events start from the second run.
- State lives in the named key-value store `change-monitor-state-v1`. To re-baseline a page,
  delete its key, or use a new `stateNamespace`.

### Use cases

1. **Competitor price tracking** — schedule over 50 competitor product URLs; get `PRICE_DROP`
   events with the exact percentage the same day, without visiting each site.
2. **Restock alerts** — monitor sold-out SKUs; a `RESTOCK` event (`OUT_OF_STOCK → IN_STOCK`)
   tells your team to buy before stock disappears again.
3. **Compliance & brand protection** — watch reseller/marketplace pages for unauthorized price
   or claims changes; the line diff gives you exactly what was edited, when.
4. **Change-aware scraping pipelines** — run this first; only re-scrape pages whose
   `changeTypes` include a content change, saving crawl budget on stable pages.

### Fair use & ethics

- Monitor pages you are allowed to access; **respect robots.txt and the target site's terms**.
  Do not use this Actor to bypass paywalls, logins, or access controls — it only fetches
  publicly reachable pages and never submits credentials.
- Keep schedules reasonable (hourly is plenty for most sites) and use `proxyConfiguration`
  responsibly; aggressive polling can get your IP blocked and burdens the target.
- Price/stock detection uses published structured data and visible text; verify critical alerts
  (e.g. a big price drop) before acting on automated detection.

# Actor input Schema

## `targets` (type: `array`):

One entry per page. The first run stores a baseline; later runs report what changed since the previous check.

## `mode` (type: `string`):

TEXT compares visible text, HTML compares raw markup, JSON compares parsed JSON keys.

## `onlyReportChanges` (type: `boolean`):

When on, unchanged pages are skipped and only change events are saved.

## `ignorePatterns` (type: `array`):

Lines matching any of these regular expressions are removed before comparison (timestamps, CSRF tokens, view counters).

## `stateNamespace` (type: `string`):

Separates snapshot stores when several monitors share one Apify account.

## `maxDiffLines` (type: `integer`):

Caps added and removed line lists so the dataset stays readable.

## `proxyConfiguration` (type: `object`):

Optional. Enable if your targets rate-limit datacenter traffic.

## Actor input object example

```json
{
  "mode": "TEXT",
  "onlyReportChanges": false,
  "stateNamespace": "default",
  "maxDiffLines": 40
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("matakupanlabs/website-change-monitor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("matakupanlabs/website-change-monitor").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 '{}' |
apify call matakupanlabs/website-change-monitor --silent --output-dataset

```

## MCP server setup

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

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/5tp1OrlDUQcM7h9Kc/builds/qPUXi9UR0XdCX469P/openapi.json
