DEV Community

GuGuData
GuGuData

Posted on Originally published at gugudata.io

Build a Lightweight Webpage Change Tracker in GitHub Actions Without Headless Chrome

If you have ever maintained a scheduled job that watches public pricing pages, legal terms, or third-party API changelogs for edits, you already know the painful part: spinning up Playwright or Puppeteer in CI just to diff a handful of URLs is slow, flaky, and noisy. Random DOM attributes, A/B test wrappers, and inline CSS hashes trigger false-positive diffs even when the human-readable copy has not moved a single word.

A much cleaner pattern is Markdown-first snapshotting: convert each watched URL into normalized Markdown, save it inside a Git repository, and let git diff do the change detection for you.

In this mini-project walkthrough, we build a zero-browser webpage change tracker that runs on GitHub Actions using the GuGuData Webpage to Markdown API, complete with strict failure isolation and troubleshooting notes.


Architecture: Why Git + Markdown Beats Raw HTML Diffing

Instead of provisioning a database and a browser cluster, the repository itself becomes your audit log:

  1. A targets.json manifest lists the public URLs you want to track and their local snapshot filenames.
  2. A scheduled GitHub Actions workflow runs a small Node.js script every morning.
  3. For each URL, the script calls POST https://api.gugudata.io/v1/websitetools/url2markdown?appkey=... with {"url": "..."} in the JSON body.
  4. When conversion succeeds (HTTP 200 and dataStatus.statusCode === 200), the script writes data.result to snapshots/<name>.md.
  5. If git status --porcelain shows changes, the workflow commits the updated snapshots (or opens a Pull Request) so your team sees a clean, readable line-by-line Markdown diff—not minified HTML noise.

Want to see what the converted Markdown looks like before signing up? Hit the zero-key Webpage to Markdown Live Demo or run curl -s https://api.gugudata.io/v1/websitetools/url2markdown/demo.


Step 1: Define Your Watched URLs (targets.json)

Keep your watch list explicit. Because url2markdown converts one public HTTP/HTTPS URL per request (maximum 2,048 characters, no embedded credentials, no non-standard ports), each entry maps cleanly to one file:

[
  {
    "slug": "gugudata-home",
    "url": "https://gugudata.io/"
  },
  {
    "slug": "url2markdown-docs",
    "url": "https://gugudata.io/details/url2markdown"
  }
]
Enter fullscreen mode Exit fullscreen mode

Need to discover sub-pages from a docs index first? Pair this manifest generator with the Webpage Link Extraction API.


Step 2: Snapshot Script (scripts/snapshot.mjs)

One important contract guarantee of GuGuData's url2markdown endpoint: it never silently returns placeholder or fallback copy when conversion fails. If an upstream site times out or blocks access, the API returns HTTP 503 (with business code 500), so your script must keep the previous snapshot untouched on error rather than overwriting it with an empty file.

import { mkdir, readFile, writeFile } from "node:fs/promises";
import path from "node:path";

const APPKEY = process.env.GUGUDATA_APPKEY;
if (!APPKEY) {
  console.error("Missing GUGUDATA_APPKEY environment variable.");
  process.exit(1);
}

const targets = JSON.parse(await readFile("targets.json", "utf8"));
await mkdir("snapshots", { recursive: true });

let failures = 0;

for (const { slug, url } of targets) {
  const endpoint = new URL("https://api.gugudata.io/v1/websitetools/url2markdown");
  endpoint.searchParams.set("appkey", APPKEY);

  try {
    const res = await fetch(endpoint, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ url }),
      signal: AbortSignal.timeout(30_000),
    });

    if (!res.ok) {
      // Never log `endpoint.href` because it includes appkey
      console.warn(`[SKIP] ${slug} (${url}) -> HTTP ${res.status}`);
      failures += 1;
      continue;
    }

    const payload = await res.json();
    const markdown = payload?.data?.result;
    if (payload?.dataStatus?.statusCode !== 200 || !markdown?.trim()) {
      console.warn(
        `[SKIP] ${slug} -> statusCode=${payload?.dataStatus?.statusCode} (${payload?.dataStatus?.statusDescription})`
      );
      failures += 1;
      continue;
    }

    const outPath = path.join("snapshots", `${slug}.md`);
    await writeFile(outPath, `${markdown.trimEnd()}\n`, "utf8");
    console.log(`[OK] Updated ${outPath} (${markdown.length} chars)`);
  } catch (err) {
    console.warn(`[ERROR] ${slug}: ${err.message}`);
    failures += 1;
  }
}

if (failures === targets.length) {
  console.error("All targets failed; failing workflow run.");
  process.exit(1);
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Automate Daily Diffs in GitHub Actions

Drop this workflow into .github/workflows/watch-pages.yml and store your key in repository secrets as GUGUDATA_APPKEY:

name: Watch Public Webpages

on:
  schedule:
    - cron: "0 2 * * *"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  snapshot:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22

      - name: Fetch Markdown snapshots
        env:
          GUGUDATA_APPKEY: ${{ secrets.GUGUDATA_APPKEY }}
        run: node scripts/snapshot.mjs

      - name: Commit changes if any
        run: |
          if [ -n "$(git status --porcelain snapshots/)" ]; then
            git config user.name "snapshot-bot"
            git config user.email "bot@users.noreply.github.com"
            git add snapshots/
            git commit -m "chore(snapshots): capture webpage copy updates"
            git push
          else
            echo "No meaningful copy changes detected."
          fi
Enter fullscreen mode Exit fullscreen mode

Because there is no Chromium binary to download, each run finishes in a few seconds instead of burning minutes of CI runner time.


Troubleshooting Checklist

When wiring this into production, these are the four edge cases teams hit most often:

  1. HTTP 400 on valid-looking links: Check that the URL has no user:pass@ prefix, no explicit non-standard port (e.g., :8443), and is under 2,048 characters.
  2. Pages behind SSO or cookie walls: url2markdown only fetches publicly accessible HTTP/HTTPS URLs; it does not take session cookies or login headers.
  3. HTTP 429 or HTTP 503 spikes: Keep targets sequential (or add a short delay between requests) and treat 503 as transient—never overwrite a good snapshot file when an upstream site is down.
  4. Need structured article metadata instead of pure Markdown: If your watcher specifically needs author, publishedTime, or image candidates in JSON, switch to the Article Content Extraction API, or use Webpage Screenshot Capture when you need visual pixel evidence alongside text.

Useful Links

Top comments (0)