<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>17</id><slug>reading-sitemaps-to-discover-urls-17</slug><title>Reading sitemaps to discover URLs</title><excerpt>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.</excerpt><seriesName>Reading sitemaps to discover URLs</seriesName><seriesPart>1</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>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>What to watch for</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>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>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></paragraphs></item><item><heading>Common pitfalls</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>Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.</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>8</authorId><authorName>Hannah Novak</authorName><authorSlug>hannah-novak</authorSlug><category>Scraping Basics</category><tags><item>selenium</item><item>json</item></tags><publishedAt>2024-07-30T00:00:00.000Z</publishedAt><wordCount>188</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
