This is part 5 of our series, and this time we focus on edge cases readers asked about. 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.
What to watch for
Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.
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.
Putting it into practice
Read the site's terms of service before you start. Many sites welcome automated access within limits and say so explicitly; others ask you to use an API instead.
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.