In part 6 we take the ideas from earlier instalments and apply them to a larger, messier site. A one-off script grows into a pipeline the moment someone asks for the data again next week. A little structure early on saves a rewrite later.
A practical approach
Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.
Deduplicate as you go. The same item often appears on several listing pages, and a stable identifier such as a SKU or ID makes duplicates easy to spot.
Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.
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.
Always identify your client honestly with a descriptive User-Agent, and keep your request rate modest. A crawler that behaves like a considerate visitor is far less likely to cause problems for the site operator.
Key takeaway
Separate fetching, parsing and storing into stages, keep raw responses, make each stage re-runnable, and validate records before they reach storage.