Your Scraper's "Success" Metric Is Lying When the Site Sends You an Empty 200
Most collection pipelines count a fetch as a success when the HTTP status starts with 2. That works right up until the day a site hands you a polite 200 OK with an empty body, a consent interstitial, or a "you must enable JavaScript" shell — and your pipeline happily records zero rows as a clean run. I run a daily collector over public Telegram channel previews (no login, just the web view). Last…
Most collection pipelines believe a fetch is successful when the HTTP status begins with 2. This method works until a site responds with a polite 200 OK, an empty body, or a message requiring JavaScript. I have a daily collector for public Telegram channel previews, which provides no login but offers a web view. One month, I received a successful run with zero messages from a channel that typically produces 30+ daily.
The status codes were all 200, exceptions were zero. The log indicated everything was fine, yet the channel had modified its preview rendering for datacenter IPs. My pipeline's sole indication of any change was the absence of data.
When a collector reports 0 new records, it cannot determine the reason: nothing new, the source moved, blocked, or reshaped, or the source changed shape under the parser. A status code does not differentiate these scenarios. A 200 with a shell page is considered a total success by your metric. To address this issue, I now utilize expectation-each-run invariants. Rather than relying on the transport layer, I assert on the payload shape: presence check, fingerprint check, and floor check.
Presence check ensures that the response contains at least one element matching the selector that carried data from the previous run. If there are zero matches from a channel with hundreds of messages in its archive, it is considered a failure, not a success. Fingerprint check involves hashing the DOM skeleton of the page, stripping the text, and comparing it to the last accepted run.
A significant deviation from the previous run triggers a shape-drift and archives the sample for inspection. Floor check is based on a rolling median of daily yield. If a run falls below ~20% of the median for a source that has been active for a week, it sends an alert. Quiet days are expected, but three consecutive low-performing days on the same source warrant attention.
While this method adds roughly 40 lines of code and creates an archived-sample folder, it has proven effective. The empty-200 switch on a specific channel was identified on the same day, not three days later when I manually checked the site. The general rule is that transport success signifies the server's response to "did you deliver bytes?" while your focus should be on the data's arrival.
The cheapest contract your pipeline can make is with the payload, not the protocol. Define the smallest structure that means "data present," assert it every run, and treat a well-formed empty as the only honest zero.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to