<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>138</id><slug>headless-vs-headed-browsers-part-7-138</slug><title>Headless vs headed browsers, part 7</title><excerpt>In part 7 we take the ideas from earlier instalments and apply them to a larger, messier site. 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>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. 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>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>Be careful with relative URLs. Resolve every link against the page it came from, not against the site root, or you will request pages that do not exist.</item><item>Validate the data you extract. Prices without currencies, dates without time zones and empty fields are common sources of silent errors downstream.</item></paragraphs></item><item><heading>Putting it into practice</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></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>2</authorId><authorName>Noah Bennett</authorName><authorSlug>noah-bennett</authorSlug><category>Browser Automation</category><tags><item>playwright</item><item>selenium</item><item>testing</item><item>scrapy</item></tags><publishedAt>2024-02-08T00:00:00.000Z</publishedAt><wordCount>211</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
