In part 3 we take the ideas from earlier instalments and apply them to a larger, messier site. Infinite scroll replaces the familiar Next button with a page that keeps growing as you move down it, which means your script has to decide when there is nothing left to load.
Putting it into practice
Log every request with its URL, status code and duration. When something goes wrong at two in the morning, those logs are the difference between a quick fix and a long investigation.
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.
Step by step
Store raw responses alongside parsed output while you are developing. When a parser breaks, you can replay the saved HTML instead of hitting the site again.
Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.
Key takeaway
Scroll, wait for the item count to change, and stop when two consecutive scrolls add nothing new. Better still, find the JSON request the page makes and call it directly.