<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>32</id><slug>session-cookies-for-scrapers-part-2-32</slug><title>Session cookies for scrapers, part 2</title><excerpt>Part 2 looks at what changes when the same technique has to run every day in production. 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>2</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>Part 2 looks at what changes when the same technique has to run every day in production. 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>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>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>Time zones matter more than they seem. Store timestamps in UTC and convert only when displaying them.</item></paragraphs></item><item><heading>Putting it into practice</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>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></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>5</authorId><authorName>Chen Patel</authorName><authorSlug>chen-patel</authorSlug><category>Scraping Basics</category><tags><item>playwright</item><item>scrapy</item></tags><publishedAt>2026-03-09T00:00:00.000Z</publishedAt><wordCount>207</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
