Standardize cookie handling · Issue #933 · apify/crawlee-python · GitHub
Skip to content

Standardize cookie handling #933

Closed
apify/apify-cli
#951

Description

@Mantisus

Currently we have 3 main cookie handling mechanisms depending on the HTTP client or browser, and none work correctly.

  1. HttpxHttpClient.
    This solution is closest to expected. Cookies are stored in Session. However, we use dict which loses the cookie-domain relationship. This can cause issues during cross-domain crawling.

  2. CurlImpersonateHttpClient.
    Session knows nothing about cookies and all cookies are stored at the AsyncSession level. As a result, if we don't use proxies, all sessions have identical cookies. If we work with proxies, cookies become tied to the proxy.

  3. Playwright.
    Session knows nothing about cookies and all cookies are stored at the PlaywrightContext level, meaning all sessions working from one context will operate with the same cookies.

Activity

  1. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Jan 24, 2025
  2. changed the title [-]Standardize Cookie Handling[/-] [+]Standardize cookie handling[/+] on Jan 24, 2025
  3. B4nan commented on Jan 27, 2025

    @B4nan
    Member

    @Mantisus thanks for bringing this up. Let's split it into 3 separate PRs please.

  4. janbuchar commented on Jan 27, 2025

    @janbuchar
    Collaborator

    Regarding 1, this will probably involve changing the Session so that it uses a more sophisticated cookie jar implementation. I'm not sure if this can be made backwards compatible...

  5. B4nan commented on Jan 27, 2025

    @B4nan
    Member

    I would focus on 3 first, that feels like the biggest issue to me. Scraping multiple domains in a single crawler is not a very common use case.

  6. janbuchar commented on Jan 27, 2025

    @janbuchar
    Collaborator

    I would focus on 3 first, that feels like the biggest issue to me. Scraping multiple domains in a single crawler is not a very common use case.

    Agreed, even though 2. is similar in terms of severity (but yeah, playwright is a bit more popular)

  7. Mantisus commented on Jan 30, 2025

    @Mantisus
    CollaboratorAuthor

    2 of 3. But for multi-domain cookie support, we'd really have to go to something like http.cookiejar.CookieJar instead of dict.

  8. added a commit that references this issue on Feb 25, 2025
    6523b3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions