<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>77</id><slug>reading-sitemaps-to-discover-urls-part-4-77</slug><title>Reading sitemaps to discover URLs, part 4</title><excerpt>In part 4 we take the ideas from earlier instalments and apply them to a larger, messier site. Before you crawl a site link by link, check whether it already publishes a list of every page it wants…</excerpt><seriesName>Reading sitemaps to discover URLs</seriesName><seriesPart>4</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>In part 4 we take the ideas from earlier instalments and apply them to a larger, messier site. Before you crawl a site link by link, check whether it already publishes a list of every page it wants found. That list is usually called sitemap.xml.</item></paragraphs></item><item><heading>Going further</heading><paragraphs><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><item>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</item><item>Log every request with its URL, status code and duration. When something goes wrong at two in the morning, those logs are the difference between a quick fix and a long investigation.</item></paragraphs></item><item><heading>A practical approach</heading><paragraphs><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>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></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Look for the Sitemap line in robots.txt, follow sitemap index files to their children, and use lastmod to skip pages that have not changed.</item></paragraphs></item></sections><authorId>11</authorId><authorName>Oliver Kim</authorName><authorSlug>oliver-kim</authorSlug><category>Scraping Basics</category><tags><item>http</item><item>playwright</item><item>scrapy</item><item>selenium</item></tags><publishedAt>2023-11-11T00:00:00.000Z</publishedAt><wordCount>216</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
