<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>98</id><slug>headless-vs-headed-browsers-part-5-98</slug><title>Headless vs headed browsers, part 5</title><excerpt>For part 5, we revisit the basics with a fresh example and a few lessons learned the hard way. Running a browser without a window is faster and works on servers, but some problems are much easier to…</excerpt><seriesName>Headless vs headed browsers</seriesName><seriesPart>5</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>For part 5, we revisit the basics with a fresh example and a few lessons learned the hard way. Running a browser without a window is faster and works on servers, but some problems are much easier to understand when you can watch the browser do its work.</item></paragraphs></item><item><heading>What to watch for</heading><paragraphs><item>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.</item><item>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.</item><item>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.</item></paragraphs></item><item><heading>Putting it into practice</heading><paragraphs><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><item>Treat HTTP 429 responses as a signal, not an obstacle. Read the Retry-After header, back off, and resume at a slower pace.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Develop headed with slow motion turned on, run headless in CI, and capture screenshots or traces on failure so headless runs are still debuggable.</item></paragraphs></item></sections><authorId>4</authorId><authorName>Lucas Silva</authorName><authorSlug>lucas-silva</authorSlug><category>Browser Automation</category><tags><item>ethics</item><item>testing</item><item>selenium</item><item>json</item></tags><publishedAt>2023-10-29T00:00:00.000Z</publishedAt><wordCount>210</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
