For part 8, we revisit the basics with a fresh example and a few lessons learned the hard way. When the data you want is several levels deep and the markup has few useful attributes, XPath's ability to navigate up, down and sideways through the tree becomes very handy.

A practical approach

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

Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.

Step by step

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.

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

Anchor on a stable nearby element, then use relative paths and axes such as following-sibling and ancestor rather than absolute paths from the root.