如何在木偶戏中使用Chrome配置文件 [英] How to use chrome profile in puppeteer

查看:55
本文介绍了如何在木偶戏中使用Chrome配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Puppeteer中使用特定的个人资料.它总是以新用户身份打开Chrome.

I am unable to use specific profile in Puppeteer. It always open the chrome as a new user.

例如:我的chrome有3个配置文件.以下是我用于在特定配置文件中打开chrome的代码:

For example: I have 3 profiles for my chrome. Following is the code I am using to open chrome in specific profile:

const browser = await puppeteer.launch({
    headless: false,
    executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
    // args: ['--profile-directory="Profile 1"'],
    userDataDir:"C:\\Users\\USER_NAME\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1"
  });

但是它总是以当前用户"个人资料打开镶边.

But it always open the chrome as "Current user" profile.

推荐答案

尝试以下代码:

const browser = await puppeteer.launch({headless:false, args:[
'--user-data-dir=/user/data/directory/profile_n']
});

此处给出了完整的解释:

Full explanation is given here:

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆