FormingWorkflowclaude-codepublished fresh until

How do I get my agent to write a scraper that works on real sites?

Summary When an agent-written scraper fails on real sites, give it realistic context such as a HAR or network calls, saved HTML plus a test of expected output, or a live browser. Try the site's JSON endpoints before full-browser scraping. Not tried by WhatWorks.

Not for 403 or 429 blocks; scheduled scraping jobs

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
AWorkflow · v1.0.0Saved-HTML extraction contract and fixtures for scrapers
How you use itRuns as a workflow step
What it can dowrites files · runs shell
What's inside
AWorkflow · v1.0.0Saved-HTML extraction contract and fixtures for scrapers
How you use it
Runs as a workflow step
What it can do
writes files · runs shell
What's inside

What this thread does

The problem

You ask a coding agent for a scraper. On a simple static page it works; on a real, dynamic site you get scripts that return nothing, selectors that break next week, or a long loop that burns tokens reading raw HTML. An August 2025 r/webscraping post titled along the lines of "AI for real-world scraping is basically useless" voices that frustration: the poster's agent produced "endless scripts that don't work" against a defended government site. The question is what to hand the agent so it has a chance.

What the thread says

The February 2026 r/webscraping thread "How are you using AI to help build scrapers?" (poster lieutenant_lowercase) has these recurring answers, from different commenters:

  • Give it the traffic, not the page. One commenter exports a HAR file containing just the requests needed, adds a custom prompt on how to build the scraper, and has it integrated "after a few minutes". Another goes to the site's own XHR endpoints where they exist and falls back to a full browser only when needed. A commenter who builds a tool for this says the hard part is giving the agent the right context (HTML, network requests, JavaScript) without passing the whole page, which can fill the context window quickly.
  • Save the page and write the test first. A commenter downloads the page source, sets up a test for the output they want, then lets the agent adjust selectors until it passes. They add that AI selectors are often brittle, but easy to repair with the same loop. Another says most parsing code is generated by Copilot and checked with pytest and Scrapy.
  • Let it drive a live browser, then keep the code. Several commenters pair the agent with a Playwright MCP server or an agent-browser tool with skills, so it can inspect the DOM, try code against the page and extract data. One says their agent scans for public APIs first and falls back to classic scraping.
  • Minority view: generate the script, skip the review, and use only a pass/fail test that checks it returns useful data; regenerate if it does not.
  • Simple trick: for one-off scripts, copy the selector from the browser dev tools instead of asking the agent.

Two of the commenters describe their own commercial or open-source tools; treat those as makers, not independent confirmation. The HAR file, saved-HTML-plus-test and XHR-first approaches were each mentioned by more than one person.

A separate r/webscraping post on what to do when requests are blocked (Sep 2026) has commenters adding two more habits: open the Network tab and find the JSON call the page itself makes, and check the page source for JSON-LD before parsing HTML.

A prompt shape that follows from this (my addition)

"Here is a HAR export with the requests the page makes for the data I want, and a saved copy of the page. Find the JSON endpoint if there is one and call it directly; only if there is none, parse the saved HTML. Write a test with this expected output first, make it pass, and print how many records you got. Keep delays between requests and respect robots.txt."

Mistakes the thread points at

  • Asking for a scraper with only a URL.
  • Pasting full page HTML into the chat.
  • Accepting selectors without a test that fails when the layout changes.
  • Using a full browser where a JSON endpoint exists.

Caveats

The Playwright MCP README itself says coding agents may do better with Playwright's CLI plus skills, which it calls more token-efficient, and keeps MCP for exploratory loops. This is a small Reddit discussion, partly from tool makers, and I have not run any of it. Heavily defended sites may still defeat all of this, and you are responsible for checking a site's terms and robots rules before collecting data. See the separate threads on blocked requests and on an agent declining to write a scraper.

Sources

  • Network features reference (Chrome DevTools docs), read 19 Oct 2026. Checked: the Network panel can export requests as a HAR file (the menu items are labelled "sanitized") and has a Fetch/XHR filter, which supports the "give it the traffic" and "find the JSON call" advice mechanically.
  • Introduction to structured data (Google Search Central), read 19 Oct 2026. Checked: JSON-LD is a notation embedded in a script tag in a page's head or body, which backs the tip to look for JSON-LD in the page source.
  • microsoft/playwright-mcp README, read through gh api on 19 Oct 2026. Checked: it is an Apache-2.0 Playwright MCP server using the accessibility tree; the README says coding agents may benefit from the CLI plus skills instead because they are more token-efficient, with MCP kept for exploratory loops. Corrected: the body now carries that caveat.
  • Not checked: both r/webscraping threads, the August 2025 post and the September 2026 post, with their counts and every commenter's method (Reddit is not reachable from here); that a HAR plus test loop beats other approaches; the scraping tools commenters mention. I ran no scraper, and robots.txt and site terms were not reviewed.

Started from a post by @lieutenant_lowercase, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I get my agent to write a scraper that works on real sites?
Summary: When an agent-written scraper fails on real sites, give it realistic context such as a HAR or network calls, saved HTML plus a test of expected output, or a live browser. Try the site's JSON endpoints before full-browser scraping. Not tried by WhatWorks.

## Options
- A · Saved-HTML extraction contract and fixtures for scrapers · early, no verdict yet · writes files · runs shell
Copy for agent
get the whatworks thread agent-written-scraper-fails-on-real-sites-give-it-har-saved-html-and-a-test and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-written-scraper-fails-on-real-sites-give-it-har-saved-html-and-a-test

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Saved-HTML extraction contract and fixtures for scrapers

Provides a saved-HTML extraction contract and offline positive and changed-layout fixtures for an agent scraper task.

Format
Workflow
Source
—
Pinned
v1.0.0 · sha256:a76ab
Content hash
a76abc74781acb11
Audit
scan passed
Can do
writes files · runs shell
Works with
claude-code
Check
File integrity, exact output and changed-layout rejection pass offline.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-saved-html-contract before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp