<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>173</id><slug>exporting-scraped-data-to-csv-part-9-173</slug><title>Exporting scraped data to CSV, part 9</title><excerpt>Part 9 looks at what changes when the same technique has to run every day in production. CSV is the lingua franca of spreadsheets and the most common way scraped data leaves a project. It is also…</excerpt><seriesName>Exporting scraped data to CSV</seriesName><seriesPart>9</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>Part 9 looks at what changes when the same technique has to run every day in production. 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>Step by step</heading><paragraphs><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><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>Common pitfalls</heading><paragraphs><item>Treat HTTP 429 responses as a signal, not an obstacle. Read the Retry-After header, back off, and resume at a slower pace.</item><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></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>11</authorId><authorName>Oliver Kim</authorName><authorSlug>oliver-kim</authorSlug><category>Data Engineering</category><tags><item>javascript</item><item>selenium</item><item>playwright</item></tags><publishedAt>2024-11-07T00:00:00.000Z</publishedAt><wordCount>181</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
