<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>160</id><slug>when-to-use-an-api-instead-of-scraping-part-8-160</slug><title>When to use an API instead of scraping, part 8</title><excerpt>This is part 8 of our series, and this time we focus on edge cases readers asked about. If a site offers an API for the data you need, scraping its HTML is usually the harder, more fragile and less…</excerpt><seriesName>When to use an API instead of scraping</seriesName><seriesPart>8</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>This is part 8 of our series, and this time we focus on edge cases readers asked about. If a site offers an API for the data you need, scraping its HTML is usually the harder, more fragile and less polite option.</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>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>Going further</heading><paragraphs><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><item>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Check for a documented API, a data export or a feed first. Scrape only when none exists, and read the terms of service either way.</item></paragraphs></item></sections><authorId>11</authorId><authorName>Oliver Kim</authorName><authorSlug>oliver-kim</authorSlug><category>Ethics &amp; Law</category><tags><item>http</item><item>playwright</item><item>selenium</item></tags><publishedAt>2025-03-15T00:00:00.000Z</publishedAt><wordCount>159</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
