genetic-orange
genetic-orange4y 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
united-yellow
united-yellow4y 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' } });
});
},
],
});
genetic-orange
genetic-orangeOP4y ago
Thank you
united-yellow
united-yellow4y ago
Glad it worked out!

Did you find this page helpful?