【发布时间】:2022-01-26 19:13:24
【问题描述】:
我正在尝试自动化购买流程,但我需要激活特定的扩展程序。扩展程序本身不需要自动化。
有没有办法在 Chromium 开发模式下激活该扩展? 或者有没有办法用我的所有扩展程序打开我的正常 Chrome 会话?
提前致谢!
【问题讨论】:
标签: web-scraping bots puppeteer chromium
我正在尝试自动化购买流程,但我需要激活特定的扩展程序。扩展程序本身不需要自动化。
有没有办法在 Chromium 开发模式下激活该扩展? 或者有没有办法用我的所有扩展程序打开我的正常 Chrome 会话?
提前致谢!
【问题讨论】:
标签: web-scraping bots puppeteer chromium
您应该可以通过 Chromium > 8.0.0 来做到这一点。您可以通过class: Puppeteer, puppeteer.launch() 指定args 选项。
| Condition | Description |
|---|---|
--load-extension |
Comma-separated list of paths to extensions to load at startup. |
let browser = await puppeteer.launch({
//...
ignoreDefaultArgs: [
//...
"--disable-extensions",
args: [
//...
`--load-extension=${PATH_TO_EXTENSION}`
],
});
或者,您可以运行 Chrome 而不是 Chromium。
executablePath 是一个puppeteer.launch() 选项,可让您设置要运行的浏览器可执行文件的路径,而不是捆绑的 Chromium。
Option Description executablePathStringPath to a browser executable to run instead of the bundled Chromium. If executablePath is a relative path, then it is resolved relative to current working directory. BEWARE: Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk.
https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#puppeteerexecutablepath
【讨论】: