rival-black
rival-black2y ago

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/']);
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/']);
1 Reply

Did you find this page helpful?