Setting a cookie in Cheerio before the page request
I am trying to use Cheerio to crawl a site that authenticates via session-based cookies. I have the cookie value I want to set, but don't know where/how to set it so every page request of my Actor's run has that cookie set.
Are there pre-request callbacks I can use in Cheerio to set a cookie, or perhaps a high-level per-Actor config I can set cookie values that will persist across all sessions?
I can't find any examples or documentation for how to access the session/sessionPool not already within a Cheerio requestHandler 🤷🏻♂️
Thank you!
2 Replies
xenial-black•3y ago
you can add it as
headers.cookie
to request itself or via preNavigationHooks
other-emeraldOP•3y ago
Ah, preNavigationHooks - thank you!