Apify and Crawlee Official Forum

Updated 12 months ago

Set cookies with cheerio

I switched from playwright to cheerio because of familiarity and cannot figure out how to set cookies (specifically for auth).

In playwright I did ontext.page.context().addCookies. How do I do this in cheerio?
L
J
2 comments
One option is to simply add them to request.headers as cookie string either during enqueueing or preNavigationHooks.

Second option is to do it through session as session.setCookies https://crawlee.dev/api/core/class/Session#setCookies. This needs to be done in preNavigationHooks because you don't have the attached session in enqueueing yet
That's what I was looking for, thanks!
Add a reply
Sign up and join the conversation on Discord