other-emerald
other-emerald3y ago

Add cookie in a special request

I want to add cookie to special ajax url in pupperties: page.on('request', async (req) => { await req.continue(); // if you don't call this, it will hang indefinitely }); How to add?
3 Replies
rare-sapphire
rare-sapphire3y ago
import { PuppeteerCrawler } from 'crawlee';

const crawler = new PuppeteerCrawler({
preNavigationHooks: [
async ({ page }) => {
page.on('request', async (req) => {
req.continue({ headers: { Cookie: 'abc' } });
});
},
],
});
import { PuppeteerCrawler } from 'crawlee';

const crawler = new PuppeteerCrawler({
preNavigationHooks: [
async ({ page }) => {
page.on('request', async (req) => {
req.continue({ headers: { Cookie: 'abc' } });
});
},
],
});
other-emerald
other-emeraldOP3y ago
Thank you
rare-sapphire
rare-sapphire3y ago
Glad it worked out!

Did you find this page helpful?