I'm building a PuppeteerCrawler and I have to login to a certain website. But the website doesn't allow for multiple browsers to be using the same account at the same time. From my understanding, the session is persisted to a single IP, but how can i make that session also be exclusive to an browser instance?
I'm also using 10 input users to be rotated by the following function.
exports.authenticate = async (page) => {
const { users } = await Apify.getInput();
const user = Math.round(Math.random() * 10 );
let isLogged = await loggedCheck(page);
if (!isLogged) {
log.debug(`Cookies from cache didn't work, trying to login..`);
await page.type('input[name="email"]', users[user].username);
await page.type('input[name="password"]', users[user].password);
await page.click('input[name="submit"]');
isLogged = await loggedCheck(page);
}
if (!isLogged) {
throw new Error('Didn\'t work!');
}
};
By default, session IPs are exclusive to a browser instance and in PuppeteerCrawler
they can be managed using the SessionPool
Check this out, should be helpful: https://sdk.apify.com/docs/guides/session-management