如何在 puppeteer 中使用 chrome 配置文件 [英] How to use chrome profile in puppeteer
本文介绍了如何在 puppeteer 中使用 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"
});
但它总是将 chrome 作为当前用户"配置文件打开.
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:
在 Puppeteer 中如何从默认配置文件切换到 chrome 窗口到所需配置文件
这篇关于如何在 puppeteer 中使用 chrome 配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文