Skip to main content
Version: 22.6.1

PuppeteerNode.launch() 方法

¥PuppeteerNode.launch() method

在指定时启动具有给定参数和选项的浏览器实例。

¥Launches a browser instance with given arguments and options when specified.

puppeteer-coreoptions.executablePathoptions.channel 一起使用时,必须提供。

¥When using with puppeteer-core, options.executablePath or options.channel must be provided.

签名:

¥Signature:

class PuppeteerNode {
launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
}

参数

¥Parameters

范围

类型

描述

options

PuppeteerLaunchOptions

(可选的)配置启动行为的选项。

Returns:

Promise<Browser>

备注

¥Remarks

Puppeteer 也可用于控制 Chrome 浏览器,但它与默认下载的 Chrome 测试版本配合使用效果最佳。不保证它可以与任何其他版本一起使用。如果首选 Google Chrome(而不是用于测试的 Chrome),则建议使用 Chrome Canary开发通道 版本。有关 Chromium 和 Chrome 之间差异的说明,请参阅 本文本文 描述了 Linux 用户的一些差异。Chrome 测试说明见 这个文档

¥Puppeteer can also be used to control the Chrome browser, but it works best with the version of Chrome for Testing downloaded by default. There is no guarantee it will work with any other version. If Google Chrome (rather than Chrome for Testing) is preferred, a Chrome Canary or Dev Channel build is suggested. See this article for a description of the differences between Chromium and Chrome. This article describes some differences for Linux users. See this doc for the description of Chrome for Testing.

示例

¥Example

你可以使用 options.ignoreDefaultArgs 从默认参数中过滤掉 --mute-audio

¥You can use options.ignoreDefaultArgs to filter out --mute-audio from default arguments:

const browser = await puppeteer.launch({
ignoreDefaultArgs: ['--mute-audio'],
});