<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>72</id><slug>session-cookies-for-scrapers-part-4-72</slug><title>Session cookies for scrapers, part 4</title><excerpt>This is part 4 of our series, and this time we focus on edge cases readers asked about. Logging in once and staying logged in is a matter of keeping the cookies the server gives you and sending them…</excerpt><seriesName>Session cookies for scrapers</seriesName><seriesPart>4</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>This is part 4 of our series, and this time we focus on edge cases readers asked about. Logging in once and staying logged in is a matter of keeping the cookies the server gives you and sending them back on every later request.</item></paragraphs></item><item><heading>Putting it into practice</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><item>Be careful with relative URLs. Resolve every link against the page it came from, not against the site root, or you will request pages that do not exist.</item></paragraphs></item><item><heading>Common pitfalls</heading><paragraphs><item>Deduplicate as you go. The same item often appears on several listing pages, and a stable identifier such as a SKU or ID makes duplicates easy to spot.</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><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></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>Use a session object (requests.Session, a Playwright context) for the whole run, and check for redirects to the login page as a sign the session has expired.</item></paragraphs></item></sections><authorId>3</authorId><authorName>Priya Nakamura</authorName><authorSlug>priya-nakamura</authorSlug><category>Scraping Basics</category><tags><item>ethics</item><item>json</item><item>testing</item><item>http</item></tags><publishedAt>2025-03-14T00:00:00.000Z</publishedAt><wordCount>233</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
