{"data":{"id":198,"slug":"headless-vs-headed-browsers-part-10-198","title":"Headless vs headed browsers, part 10","excerpt":"This is part 10 of our series, and this time we focus on edge cases readers asked about. Running a browser without a window is faster and works on servers, but some problems are much easier to…","seriesName":"Headless vs headed browsers","seriesPart":10,"sections":[{"heading":"Introduction","paragraphs":["This is part 10 of our series, and this time we focus on edge cases readers asked about. 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."]},{"heading":"A practical approach","paragraphs":["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.","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."]},{"heading":"Common pitfalls","paragraphs":["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.","Before writing a single line of code, look at how the page actually loads its data. Open the network panel, reload, and note which requests return the content you care about. Very often the data you want arrives as JSON from an endpoint you can call directly."]},{"heading":"Key takeaway","paragraphs":["Develop headed with slow motion turned on, run headless in CI, and capture screenshots or traces on failure so headless runs are still debuggable."]}],"authorId":11,"authorName":"Oliver Kim","authorSlug":"oliver-kim","category":"Browser Automation","tags":["ethics","selenium"],"publishedAt":"2024-06-28T00:00:00.000Z","wordCount":206,"readingTimeMinutes":2}}