Ingestion · 2026
Collecting web data without losing the failures
LaboratoryIndependent engineer
A data collection process that restarts on every crash, shares one rate limit across every source, and mixes broken records into the same table as valid ones quickly becomes unreliable and hard to trust.
The constraint
This is a laboratory reference build with no client metrics claimed. It ships with four sample sources, including one JavaScript-rendered page wrapped in Camoufox. All automated tests run offline against frozen HTML fixtures so external site changes do not break the test suite.
Built with
PythonCamoufoxSQLiteDocker
How it works
YAML configs define each source. Camoufox and HTTP fetchers write a raw HTML cache. Parsers validate and deduplicate into SQLite, parking bad rows in a dead-letter table.
Architectural calls and their cost
Every design choice, the operational pressure behind it, what it bought, and the ongoing maintenance cost.
YAML per source
Rate limits, selectors, and retries differ per source. Kept in a shared module they become globals, and one source's change turns into every source's risk.
Each target site gets its own YAML file defining rate limits, CSS selectors, and retry rules, isolating per-source tuning so fixing one scraper leaves the others unaffected.
The cost: Adding a source is a config file plus a parser, and there is no single place that lists them all.
Cache the raw HTML
A crash partway through a run should not mean fetching the corpus again, and a parser change should be testable against the pages it already saw.
The fetcher writes raw HTML to disk before running any parser logic, allowing instant local replays after a parser tweak without hitting the remote server twice.
The cost: Storage grows with every run, and the cache becomes something to manage.
Two-stage deduplication and dead-letter queue
A broken record that reaches the clean table is worse than a missing one: the table looks complete while it is wrong.
Records pass through URL and content-hash deduplication plus schema validation, routing malformed rows to a dead-letter table while respecting server Retry-After headers. Downstream SQLite queries read only validated rows.
The cost: Two storage paths to maintain, plus an operator must periodically inspect the dead-letter table.
Most web scraping scripts work on the day they are written and rot within a month. They share one global rate limit across every target site, refetch thousands of pages from scratch whenever a parser crashes on row 900, and insert partial or broken records straight into the main database table.
This laboratory codebase packages the four safeguards I use on client data pipelines into a reusable Python, Camoufox, SQLite, and Docker template. First, every source has its own YAML manifest for selectors, headers, and backoff rules. Second, the fetcher caches raw HTML responses on disk before parsing, so fixing a broken selector is a fast local replay rather than another network crawl.
Third, deduplication checks both request URLs and content hashes before validation routes any malformed record into a separate dead-letter table. Your reporting table only ever receives complete, schema-validated rows. Finally, the test suite runs entirely offline against frozen HTML snapshots, proving parser changes before anything touches a live site.
Current status and proof
Laboratory. A reliable pattern for collecting and validating web data, ready to apply to a client's data source.
- Four demo sources ship with the codebase, including a JavaScript-rendered page fetched via Camoufox.
- Automated tests run offline against frozen HTML fixtures so live websites cannot break the suite.
- Invalid rows route to a dead-letter table while validated rows land in SQLite, with retries honouring server rate limits.
- Laboratory pattern, with no client metrics behind it.
What was handed over
- How to add a source in YAML
- How to run the tests offline
- Schema and query guide for inspecting and replaying rows from the dead-letter table