<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>52</id><slug>session-cookies-for-scrapers-part-3-52</slug><title>Session cookies for scrapers, part 3</title><excerpt>For part 3, we revisit the basics with a fresh example and a few lessons learned the hard way. Logging in once and staying logged in is a matter of keeping the cookies the server gives you and…</excerpt><seriesName>Session cookies for scrapers</seriesName><seriesPart>3</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>For part 3, we revisit the basics with a fresh example and a few lessons learned the hard way. 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>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><item>Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.</item><item>Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.</item></paragraphs></item><item><heading>Common pitfalls</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>Before writing a single line of code, look at how the page actually loads its data. Open the network panel, reload, and note which requests return the content you care about. Very often the data you want arrives as JSON from an endpoint you can call directly.</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 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>11</authorId><authorName>Oliver Kim</authorName><authorSlug>oliver-kim</authorSlug><category>Scraping Basics</category><tags><item>json</item></tags><publishedAt>2026-05-09T00:00:00.000Z</publishedAt><wordCount>263</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
