puppeteer-cluster icon indicating copy to clipboard operation
puppeteer-cluster copied to clipboard

Multiple instance open in incognito browser how to open multiple instance in normal browser

Open Umerhasan97 opened this issue 3 years ago • 2 comments

Sir i am open puppeteer cluster in multiple browser instance but thus parallel multiple browser instance open in incognito mode and cookies not shared one instance to another instance how to open browser instance cluster in without incognito and share cookies one instance to another

Umerhasan97 avatar Jul 30 '21 08:07 Umerhasan97

Almost the same issue, is there any way to open multiple browser instances in normal mode?

farruhsydykov avatar Oct 12 '21 16:10 farruhsydykov

@farruhsydykov @Umerhasan97 this is my solution

create file concurrency.js ` const ConcurrencyImplementation = require('puppeteer-cluster/dist/concurrency/ConcurrencyImplementation'); const BROWSER_TIMEOUT = 5000;

class Normal extends ConcurrencyImplementation.default{

async init() {}
async close() {}

async workerInstance(){

    const options = this.options;
    let chrome = await this.puppeteer.launch(options);
    let page;

    return {
        jobInstance: async () => {

            /*await timeoutExecute(BROWSER_TIMEOUT, (async () => {
               
            })());*/

            const pages = await chrome.pages();
            page = pages[0];

            return {
                resources: {
                    page,
                },

                close: async () => {
                    //await timeoutExecute(BROWSER_TIMEOUT, page.close());
                    await page.close();
                },
            };
        },

        close: async () => {
            await chrome.close();
        },

        repair: async () => {
        
            try {
                // will probably fail, but just in case the repair was not necessary
                await chrome.close();
            } catch (e) {}

            // just relaunch as there is only one page per browser
            chrome = await this.puppeteer.launch(options);
        },
    };
}

}

module.exports = Normal const currency = require('./concurrency.js'); const cluster = await Cluster.launch({

    concurrency: currency,
    maxConcurrency: 2,
    puppeteer,

}); ` this should work, by opening a separate browser with a url in the first tab

CarmenLexa avatar Feb 16 '22 14:02 CarmenLexa