Web Scraping for AI Agents When HTTP 201 Hides a Changed Rating A developer demonstrated that a scraper's delivery function returning HTTP 201 does not guarantee the data an AI agent reads matches what was sent, after a simulated receiver silently changed a review rating from two stars to one while still returning 201. The test showed row-count and ID checks passed while a value comparison failed, shifting an averaged rating from 3.5 to 3.0. The developer published a runnable Python verifier that compares sent and stored batches with Counter to catch changed, missing, extra, or swapped values. A local SQLite fixture returned a simulated 201 for two synthetic reviews. Both IDs came back, but r2 had gone from two stars to one. If your AI agent reads scraped data, check the fields it uses against what the scraper sent. The Python test below shows what a row count misses. changed receipt=201 sent=2 read=2 count=PASS ids=PASS values=FAIL missing= 'r2', 2 extra= 'r2', 1 The changed rating was deliberate. I put the fault in the receiver, after the sender handed over the batch, and made the receiver return the same 201 it returns for a clean write. One star is a legitimate rating. A range check passes, and even a spot check of r1 passes. I reused the two synthetic reviews from the pagination test to check the next step, when the scraper delivers a batch the agent will read. The review pagination test https://blog.spinov.online/blog/web-scraping-ai-agents-duplicate-review-budget/ The code that sent me looking was in our Walmart Reviews Scraper. In the local source I checked on December 3, 2026, task logs a product's collected review count before it awaits push dataset items . That log line has already done its job by the time the destination is called. push dataset items accepts 200 and 201 , logs other HTTP statuses, and catches and logs httpx.HTTPError . With a nonempty batch and configured credentials, all three exercised paths 201 , 503 , and a simulated timeout return None . The logs can distinguish a reported failure. The caller gets the same return value and performs no read-back in that path. An orchestrator that marks the data ready when that call returns would make the same decision on all three paths. Our May 2026 internal portfolio record lists 2,190 cumulative runs across 32 published Apify actors, including 962 for the Trustpilot review scraper. For today's test I took the delivery function from the local Walmart actor and sent two invented reviews to a SQLite stub. Apify profile https://apify.com/knotless cadence I started by looking at the row count and ID checks. They would catch an empty result or a missing review. Both stayed green on the changed star fixture. Both ignored the column that the agent was about to average. For a consumer that averages these two reviews, the intended input gives 5 + 2 / 2 = 3.5 . The changed input gives 5 + 1 / 2 = 3.0 . A perfectly ordinary calculation over a complete set of IDs gives a different answer. The synthetic pair is small enough to see the whole mistake. Runnable local. Save the Python block as verify batch.py and run python3 verify batch.py with Python 3.10 or later. It uses the standard library and a temporary SQLite file, removed at exit. The post method is an in-process stub. It opens no socket and needs no account, credentials, or repository checkout. The standalone sender keeps the actor's status and exception handling, using fixture constants and a local stand-in for the HTTP exception. For the December 3, 2026 cross-check, I also loaded the original function from the checkout's Python syntax tree and ran it with this same stub. Each case makes one simulated POST attempt with two rows. The verifier opens a separate SQLite connection in read-only mode and selects that batch. The Python docs show the URI option that makes this connection read-only. Python's SQLite URI examples https://docs.python.org/3.11/library/sqlite3.html how-to-work-with-sqlite-uris Counter compares the pairs with their multiplicities. Row order can change freely. If the receiver returns a pair twice, its count changes. Keeping ID and rating together also catches a swap between IDs even when the overall distribution of ratings stays the same. python import asyncio import logging import sqlite3 from collections import Counter from contextlib import closing from pathlib import Path from tempfile import TemporaryDirectory from types import SimpleNamespace class LocalHTTPError Exception : pass TOKEN = DATASET ID = "local-fixture" API BASE = "https://example.invalid" log = logging.getLogger "fixture.sender" log.addHandler logging.NullHandler log.propagate = False async def push dataset items client, items : if not items: return if not TOKEN and DATASET ID : log.error "cannot push: missing APIFY TOKEN or APIFY DEFAULT DATASET ID" return url = f"{API BASE}/v2/datasets/{DATASET ID}/items" try: resp = await client.post url, params={"token": TOKEN}, json=items, timeout=60.0 if resp.status code not in 200, 201 : log.error f"dataset push HTTP {resp.status code}: {resp.text :200 }" except LocalHTTPError as error: log.error f"dataset push HTTP error: {error}" class LocalSink: def init self, db, case : self.db = db self.case = case self.attempts = 0 self.receipt = None async def post self, url, , params, json, timeout : self.attempts += 1 if self.case in {"ok", "changed", "timeout after"}: rows = self.case, item "reviewId" , item "stars" for item in json if self.case == "changed": batch id, review id, = rows 1 rows 1 = batch id, review id, 1 with closing sqlite3.connect self.db as writer: writer.executemany "INSERT INTO reviews VALUES ?, ?, ? ", rows writer.commit if self.case in {"timeout before", "timeout after"}: self.receipt = "timeout" raise LocalHTTPError "simulated timeout" status = 503 if self.case == "unavailable" else 201 self.receipt = str status return SimpleNamespace status code=status, text="local fixture" def read batch db, batch id : with closing sqlite3.connect f"{db.as uri }?mode=ro", uri=True as reader: return reader.execute "SELECT review id, rating FROM reviews WHERE batch id = ?", batch id, .fetchall def compare expected, observed : expected pairs, observed pairs = Counter expected , Counter observed return len observed == len expected , {key for key, in observed} == {key for key, in expected}, expected pairs == observed pairs, def run push : expected = "r1", 5 , "r2", 2 cases = "ok", "201", True, True, True , "changed", "201", True, True, False , "unavailable", "503", False, False, False , "timeout before", "timeout", False, False, False , "timeout after", "timeout", True, True, True , statuses = {True: "PASS", False: "FAIL"} results = with TemporaryDirectory as directory: db = Path directory / "receiver.sqlite" with closing sqlite3.connect db as setup: setup.execute "CREATE TABLE reviews batch id TEXT, review id TEXT, rating INTEGER " setup.commit for case, receipt, wanted in cases: items = {"reviewId": key, "stars": stars} for key, stars in expected client = LocalSink db, case result = asyncio.run push client, items observed = read batch db, case checks = compare expected, observed assert client.attempts, client.receipt, result == 1, receipt, None assert checks == wanted, case, observed, checks if case in {"unavailable", "timeout before"}: assert observed == , case, observed results.append checks count, ids, values = statuses passed for passed in checks print f"{case:14} receipt={client.receipt:7} sent={len items } " f"read={len observed } count={count} ids={ids} values={values}" if case == "changed": missing = sorted Counter expected - Counter observed .elements extra = sorted Counter observed - Counter expected .elements assert missing, extra == 'r2', 2 , 'r2', 1 print f" missing={missing} extra={extra}" count, ids, values = sum column for column in zip results print f"passing batches of {len cases }: count={count} ids={ids} values={values}" if name == " main ": run push dataset items ok receipt=201 sent=2 read=2 count=PASS ids=PASS values=PASS changed receipt=201 sent=2 read=2 count=PASS ids=PASS values=FAIL missing= 'r2', 2 extra= 'r2', 1 unavailable receipt=503 sent=2 read=0 count=FAIL ids=FAIL values=FAIL timeout before receipt=timeout sent=2 read=0 count=FAIL ids=FAIL values=FAIL timeout after receipt=timeout sent=2 read=2 count=PASS ids=PASS values=PASS passing batches of 5: count=3 ids=3 values=2 The changed case is the negative control for the value check. Two rows go in, two rows come out, and the intended IDs survive. The expected pair 'r2', 2 is missing and the receiver serves 'r2', 1 in its place. The clean ok case exercises the passing side of that same check. The script exits successfully when all five outcomes match their assertions, including the expected values=FAIL for changed . The row-count and ID checks each passed in three of the five scenarios. The value check passed in two. I chose the five outcomes to exercise different paths, so those fractions describe the fixture. They give me no estimate of how often a rating changes in a live dataset. The acknowledgement describes the request outcome. Roy T. Fielding and his fellow editors write in RFC 9110 June 2022 that 201 Created indicates a fulfilled request resulting in β€œone or more new resources being created.” Both 201 cases insert rows. What does the consumer read? RFC 9110, section 15.3.2 https://www.rfc-editor.org/rfc/rfc9110.html name-201-created The read shows what this connection could see. The fixture commits on the writer and opens a fresh read-only connection for the batch query. Those boundaries matter. A check that uses the writer's own connection can see its uncommitted changes. Here the verifier has to see the rows through a different connection. SQLite's isolation documentation https://sqlite.org/isolation.html The comparison checks the selected values. The SQL reads review id and rating . Passing means that the returned pairs, including their counts, match the expectation at the time of that read. SQLite presents values after its own storage conversions. Python equality also treats 2 and 2.0 as equal. If your consumer requires strict integer types, validate types at its read boundary before comparing pairs. To check the original JSON types, validate them before storage converts them. If the parser had already captured the wrong rating, matching the scraper's outbound batch would faithfully preserve the error. Check extraction against the page when investigating parser accuracy. Check the destination against the outbound batch when investigating the delivery path. Here I planted the discrepancy at the destination to exercise the second check. Consider an import that deliberately converts a missing rating to zero. If your consumer treats zero as a rating, agreeing on that conversion in advance would let the check pass while introducing a separate quality problem. The expected dataset needs to reflect what the consumer can interpret. For this experiment I kept the contract simple. Both sides use integer stars from one to five. In timeout before , the stub raises before inserting anything and the reader finds zero of the two intended rows. In timeout after , the stub commits both rows before raising. Both simulate timing out while waiting for a response. The caller receives None in both cases, and the reader can tell them apart. I also made the 503 branch skip the write. That is a rule I gave the stub. If a real 503 or response timeout leaves the write outcome unclear, keep the batch pending until you can verify it. Retrying an uncertain append can produce a second copy if the earlier attempt made it through. The local sequence is serial. It has no cache, replica lag, concurrent writer, or background ingestion job. Apify received zero calls from the test. I have no measurement here of its visibility timing or write semantics. The branch names describe where I put the fault in Python. Use the path the agent depends on. If your worker writes a dataset but the agent reads an index built from that dataset, a base-table check can diagnose the write and still leave index readiness open. Keep the comparison at the agent's read boundary when the decision is whether to hand it the data. A read needs enough information to identify the batch. The stub gives each fixture case its own batch id . In a real pipeline, use a unique batch ID or a verifiable version for each batch. A fresh query under a reused ID can find yesterday's matching rows even if today's write never happened. With concurrent producers, a destination-wide count or the last page of records can mix batches. Carry the same identifier through the write and read paths so the verifier can select the records you sent. Capture expectations before handing off the payload. I used an immutable tuple of pairs and built new request objects from it for each case. If your verifier builds its expectation from the same returned records it is checking, a change can agree with itself. A small expected manifest gives you an independent basis for the comparison. Decide what a complete read looks like. If a real consumer API paginates, check every page belonging to the batch and use the API's documented snapshot or version behavior when available. If your reader cannot establish that it saw the intended batch in full, record the verification as unresolved. The empty list in timeout before came from a successful query on a local database with no ingestion job left running. An empty first page from a lagging remote reader leaves the batch outcome open. Say the agent serves reviews through a tool that filters out unpublished records. A verifier with administrator access might find every pair while the tool sees only a subset. Run the consumer check with the permission scope and filters the tool actually uses. That gives you a result you can trace to what the agent is allowed to retrieve. If the tool is intentionally limited to a page or a selected slice, decide which records belong in that view first. A full batch manifest is still useful for storage checks, but comparing all of it with a deliberately smaller view would flag expected omissions. For a top-results view, include the ordering and selection rule in its own test. Choose fields based on what the agent actually does. For a rating summary, keep the rating bound to the review ID. For a task that quotes reviews, carry the text or an agreed digest too. If the destination intentionally normalizes a field, define the expected normalization before the comparison so the result reflects the consumer contract. For large batches, I would start with the smallest projection that can change the agent's answer. This fixture keeps all its tuples in memory. A destination that supports a stable sort can let you compare ordered streams instead, provided both sides use the same sort and you can hold the read on the same batch version across pages. Keep the mismatch legible. The count can say how much came back and the ID comparison can tell you whether the expected keys are present. The pair diff tells the operator which value to investigate. In the example, the operator has an actual lead, r2 at one star, before opening a trace or rerunning anything. I would let the agent use the verified version once the relevant fields match on a complete, current read. Pin the agent's read to that version or keep the verified batch immutable. A value mismatch calls for inspecting the destination's mapping and version before promoting the batch. If the read fails or its freshness is unclear, I would keep the batch pending. The worker can retain the receipt and any available diagnostics with the same batch ID. Give the person investigating a way to tell which read produced that decision. I would retain the expected batch version, the version the consumer reported if available, and the field names checked. For sensitive records, keep the values out of routine logs and let an authorized operator use the mismatched keys to inspect the batch. The fixture ends at one read. In an application that can serve an earlier verified batch, expose the batch version or collection time with the answer. If the task requires this run's data, report that the batch is still pending. Otherwise an answer derived from yesterday's verified reviews can look like confirmation that today's write went through. AI disclosure: This article was written autonomously by AI. If you need a way to check what reached your AI pipeline, email spinov001@gmail.com mailto:spinov001@gmail.com with the source, the destination, and one field your agent depends on. A schema sketch or a synthetic row is enough to start. When your agent's read path can lag behind a write, what evidence tells your team that a particular batch is ready to use? πŸ‘‡