javascript - how to launch puppeteer with an already existing profile multiple time - Stack Overflow

so am trying to launch puppeteer with already existed chrome profile and it works , but what i want to

so am trying to launch puppeteer with already existed chrome profile and it works , but what i want to do is to launch the same process multiple time which throw an error

(node:12820) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! [0311/152606.490:ERROR:chrome_main_delegate(679)] Web security may only be disabled if '--user-data-dir' is also specified with a non-default value

am doing it in this way :

 const browser = await puppeteer.launch({
    executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
    headless: false,
    // excludeSwitches: 'enable-automation',
    args: [

      '--user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data'
    ],
  });

so am trying to launch puppeteer with already existed chrome profile and it works , but what i want to do is to launch the same process multiple time which throw an error

(node:12820) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! [0311/152606.490:ERROR:chrome_main_delegate(679)] Web security may only be disabled if '--user-data-dir' is also specified with a non-default value

am doing it in this way :

 const browser = await puppeteer.launch({
    executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
    headless: false,
    // excludeSwitches: 'enable-automation',
    args: [

      '--user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data'
    ],
  });
Share Improve this question asked Mar 11, 2021 at 13:33 DUMBUSERDUMBUSER 5518 silver badges25 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 6 +50

As far as I can tell Puppeteer doesn't allow itself to be launched more than once for the same userDataDir because that folder includes a caching folder which must be unique per puppeteer instance. You can however open multiple pages using the same browser instance. For example:

   const browser = await puppeteer.launch({
      executablePath: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
      headless: false,
      // excludeSwitches: 'enable-automation',
      args: [
         '--user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data'
      ],
   });
   const page1 = await browser.newPage();
   const page2 = await browser.newPage();
   await page1.goto("https://www.bbc.co.uk", {waitUntil: 'networkidle2'});
   await page2.goto("https://www.google.co.uk", {waitUntil: 'networkidle2'});

If you truly need pletely isolated Puppeteer processes you'll need to launch each with its own unique userDataDir. You could try building a lightweight profile with just the config files you need and making a copy for each process you launch.

Sorry, that this isn't really a perfect solution but I don't think what you're trying to do is possible.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742301595a4418132.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信