<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>130</id><slug>choosing-css-selectors-that-survive-redesigns-part-7-130</slug><title>Choosing CSS selectors that survive redesigns, part 7</title><excerpt>In part 7 we take the ideas from earlier instalments and apply them to a larger, messier site. A selector that worked yesterday and fails today is usually a selector that depended on something nobody…</excerpt><seriesName>Choosing CSS selectors that survive redesigns</seriesName><seriesPart>7</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>In part 7 we take the ideas from earlier instalments and apply them to a larger, messier site. A selector that worked yesterday and fails today is usually a selector that depended on something nobody promised to keep the same, such as a generated class name or the position of a div.</item></paragraphs></item><item><heading>A practical approach</heading><paragraphs><item>Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.</item><item>Pagination comes in several shapes: numbered pages, next links, offsets and opaque cursors. Each has trade-offs, and a robust scraper should detect the end of the result set rather than assuming a fixed number of pages.</item></paragraphs></item><item><heading>Common pitfalls</heading><paragraphs><item>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.</item><item>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.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Prefer data-testid attributes, ARIA roles and visible labels. Avoid long chains of nth-child and anything that looks like a hash.</item></paragraphs></item></sections><authorId>1</authorId><authorName>Amelia Okafor</authorName><authorSlug>amelia-okafor</authorSlug><category>Testing</category><tags><item>javascript</item><item>selenium</item><item>http</item></tags><publishedAt>2026-04-12T00:00:00.000Z</publishedAt><wordCount>186</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
