{"data":{"id":173,"slug":"exporting-scraped-data-to-csv-part-9-173","title":"Exporting scraped data to CSV, part 9","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…","seriesName":"Exporting scraped data to CSV","seriesPart":9,"sections":[{"heading":"Introduction","paragraphs":["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."]},{"heading":"Step by step","paragraphs":["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.","Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy."]},{"heading":"Common pitfalls","paragraphs":["Treat HTTP 429 responses as a signal, not an obstacle. Read the Retry-After header, back off, and resume at a slower pace.","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."]},{"heading":"Key takeaway","paragraphs":["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."]}],"authorId":11,"authorName":"Oliver Kim","authorSlug":"oliver-kim","category":"Data Engineering","tags":["javascript","selenium","playwright"],"publishedAt":"2024-11-07T00:00:00.000Z","wordCount":181,"readingTimeMinutes":2}}