<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>153</id><slug>exporting-scraped-data-to-csv-part-8-153</slug><title>Exporting scraped data to CSV, part 8</title><excerpt>In part 8 we take the ideas from earlier instalments and apply them to a larger, messier site. CSV is the lingua franca of spreadsheets and the most common way scraped data leaves a project. It is…</excerpt><seriesName>Exporting scraped data to CSV</seriesName><seriesPart>8</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>In part 8 we take the ideas from earlier instalments and apply them to a larger, messier site. CSV is the lingua franca of spreadsheets and the most common way scraped data leaves a project. It is also surprisingly easy to produce a CSV that opens incorrectly.</item></paragraphs></item><item><heading>What to watch for</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>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>A practical approach</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>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>Key takeaway</heading><paragraphs><item>Use a proper CSV writer rather than joining strings, quote fields that contain commas or newlines, write UTF-8, and keep dates in ISO 8601.</item></paragraphs></item></sections><authorId>2</authorId><authorName>Noah Bennett</authorName><authorSlug>noah-bennett</authorSlug><category>Data Engineering</category><tags><item>testing</item><item>ethics</item></tags><publishedAt>2024-05-31T00:00:00.000Z</publishedAt><wordCount>184</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
