Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add cookies for context? #21

Closed
Xzeffort opened this issue Jul 31, 2021 · 1 comment
Closed

How to add cookies for context? #21

Xzeffort opened this issue Jul 31, 2021 · 1 comment

Comments

@Xzeffort
Copy link

The code:

scrapy.Request(
            url=url,
            cookies=cookies,
            ...
)

It is not available.
But I use this method:await page.context.add_cookies(cookies=c) in parse, it is available, but this method is too bad.

@elacuesta
Copy link
Member

Sending cookies using the Request.cookies argument does work, please check the examples/cookies.py script.
An alternative could be to pass storage_state.cookies (see this page for reference) when creating the browser contexts (either at startup with the PLAYWRIGHT_CONTEXTS setting or during a crawl with the playwright_context_kwargs request meta key).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants