verbal-limeV
Apify & Crawlee2y ago
1 reply
verbal-lime

How to manage correctly Login and Session in Playwright?

Hi everyone,

I have the following scenario. I have a base login URL like "https://www.facebook.com/login/" and from there I put my details in and wanna que some links. But for each link i need the session or the login. How would it be the correct way to do this?

I tried with persistCookiesPerSession but that did not work. Thanks in advanced for the Help.

import { PlaywrightCrawler} from 'crawlee';

const crawler = new PlaywrightCrawler({

    async requestHandler({ request, page, enqueueLinks, log }) {
        const title = await page.title();
        log.info(`Title of ${request.loadedUrl} is '${title}'`);
        //Some Login Function comes here
        await enqueueLinks();
    },
    maxRequestsPerCrawl: 50,
    persistCookiesPerSession: true,
});

await crawler.run(['https://www.facebook.com/login/']);
Was this page helpful?