Part 4 looks at what changes when the same technique has to run every day in production. Running a browser without a window is faster and works on servers, but some problems are much easier to understand when you can watch the browser do its work.

Putting it into practice

Selectors are the most fragile part of any scraper. Prefer stable attributes such as data-testid or semantic structure over generated class names, which can change on every deploy.

Character encodings still cause trouble. Decode responses using the charset the server declares, and normalise text before comparing or storing it.

Be careful with relative URLs. Resolve every link against the page it came from, not against the site root, or you will request pages that do not exist.

What to watch for

Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.

Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.

Dynamic pages render content after the initial HTML arrives. A browser automation tool can wait for a specific element to appear, which is far more reliable than sleeping for a fixed amount of time.

Key takeaway

Develop headed with slow motion turned on, run headless in CI, and capture screenshots or traces on failure so headless runs are still debuggable.