<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>36</id><slug>detecting-lazy-loaded-content-part-2-36</slug><title>Detecting lazy-loaded content, part 2</title><excerpt>Part 2 looks at what changes when the same technique has to run every day in production. Lazy loading defers images and sections until they are about to scroll into view. A script that reads the page…</excerpt><seriesName>Detecting lazy-loaded content</seriesName><seriesPart>2</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>Part 2 looks at what changes when the same technique has to run every day in production. Lazy loading defers images and sections until they are about to scroll into view. A script that reads the page immediately sees placeholders instead of content.</item></paragraphs></item><item><heading>Common pitfalls</heading><paragraphs><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><item>Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.</item></paragraphs></item><item><heading>Putting it into practice</heading><paragraphs><item>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.</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></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Scroll the element into view and wait for its real attributes to appear, or read the data-src style attributes that hold the eventual values.</item></paragraphs></item></sections><authorId>2</authorId><authorName>Noah Bennett</authorName><authorSlug>noah-bennett</authorSlug><category>Browser Automation</category><tags><item>javascript</item><item>ethics</item><item>python</item><item>scrapy</item></tags><publishedAt>2024-10-01T00:00:00.000Z</publishedAt><wordCount>180</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
