简体   繁体   English

Puppeteer 中的默认 executablePath 是什么?

[英]What is default executablePath in Puppeteer?

This initialization works well even if we are not passing executablePath in LaunchOptions in puppeteer.launch()即使我们没有在LaunchOptions puppeteer.launch()的 LaunchOptions 中传递executablePath ,这个初始化也能正常工作

const browser = await puppeteer.launch();

What is default value of executablePath ? executablePath的默认值是多少?

The default value of the executablePath option in the puppeteer.launch() function is null . puppeteer.launch()函数中executablePath选项的默认值为null This means that Puppeteer will use the default installation of Chrome or Chromium on the system to launch the browser.这意味着 Puppeteer 将使用系统上默认安装的 Chrome 或 Chromium 来启动浏览器。

If you have multiple versions of Chrome or Chromium installed on your system, or if you want to use a specific version of the browser, you can specify the path to the executable in the 'executablePath' option.如果您的系统上安装了多个版本的 Chrome 或 Chromium,或者如果您想使用特定版本的浏览器,则可以在“executablePath”选项中指定可执行文件的路径。 For example:例如:

const browser = await puppeteer.launch({
  executablePath: '/path/to/chrome'
});

If you do not specify a value for the executablePath option, Puppeteer will try to find the default installation of Chrome or Chromium on the system.如果您没有为executablePath选项指定值,Puppeteer 将尝试在系统上查找 Chrome 或 Chromium 的默认安装。 On Windows, this is usually C:\Program Files (x86)\Google\Chrome\Application\chrome.exe .在 Windows 上,这通常是C:\Program Files (x86)\Google\Chrome\Application\chrome.exe On macOS and Linux, Puppeteer will try to use the chrome or chromium executable in the PATH .在 macOS 和 Linux 上,Puppeteer 将尝试在PATH中使用 chrome 或 chromium 可执行文件。

The path will change based on the platform that you install puppeteer on.该路径将根据您安装 puppeteer 的平台而改变。

https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer/src/node/install.ts https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer/src/node/install.ts
has methods for finding that path.有找到那条路径的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 node.js win10 puppeteer 可执行路径字符串 - node.js win10 puppeteer executablePath string 获取 puppeteer 页面的默认超时设置 - Get default timeout settings for puppeteer page Puppeteer 中的 jsHandle 和 elementHandle 有什么区别? - What is the difference between jsHandle and elementHandle in Puppeteer? 什么是`document.elementFromPoint`的puppeteer api? - What's puppeteer api for `document.elementFromPoint`? 在 Puppeteer 中如何从默认配置文件切换到 chrome 窗口到所需的配置文件 - In Puppeteer how to switch to chrome window from default profile to desired profile 在 userPrefs 中设置什么以在 puppeteer-extra 底部打开 devtools? - What to set in userPrefs to open devtools at the bottom in puppeteer-extra? 通过管道而不是 websocket 连接 Puppeteer 的优缺点是什么 - What are the advantages and disadvantages of connecting Puppeteer over pipe instead of a websocket 木偶:包含异步功能的圆括号是什么意思? - Puppeteer: What do the round brackets enclosing an async function mean? 当我们调用 puppeteer waitForSelector API 时会发生什么 - What happens when we call puppeteer waitForSelector API puppeteer 脚本阻止将抓取的数据保存到文件有什么问题? - What is wrong is the puppeteer script that stops it saving the scraped data to a file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM