Skip to main content
Version: 24.38.0

Configuration 接口

🌐 Configuration interface

定义在安装和运行时配置 Puppeteer 行为的选项。

🌐 Defines options to configure Puppeteer's behavior during installation and runtime.

有关详细信息,请参阅各个属性。

🌐 See individual properties for more information.

语法

🌐 Signature

export interface Configuration

属性

🌐 Properties

属性

🌐 Property

修饰符

🌐 Modifiers

类型

🌐 Type

描述

🌐 Description

默认

🌐 Default

"chrome-headless-shell"

optional

ChromeHeadlessShell设置

cacheDirectory

optional

string

定义 Puppeteer 用于缓存的目录。

🌐 Defines the directory to be used by Puppeteer for caching.

可以被 PUPPETEER_CACHE_DIR 覆盖。

🌐 Can be overridden by PUPPETEER_CACHE_DIR.

path.join(os.homedir(), '.cache', 'puppeteer')

chrome

optional

Chrome设置

defaultBrowser

optional

支持的浏览器

指定你希望 Puppeteer 使用的浏览器。

🌐 Specifies which browser you'd like Puppeteer to use.

可以被 PUPPETEER_BROWSER 覆盖。

🌐 Can be overridden by PUPPETEER_BROWSER.

chrome

executablePath

optional

string

指定在 puppeteer.launch 中使用的可执行文件路径。

🌐 Specifies an executable path to be used in puppeteer.launch.

可以被 PUPPETEER_EXECUTABLE_PATH 覆盖。

🌐 Can be overridden by PUPPETEER_EXECUTABLE_PATH.

自动计算。

experiments

optional

实验配置

定义 Puppeteer 的实验选项。

🌐 Defines experimental options for Puppeteer.

firefox

optional

Firefox设置

logLevel

optional

'silent' | 'error' | 'warn'

告诉 Puppeteer 在给定级别进行日志记录。

🌐 Tells Puppeteer to log at the given level.

warn

skipDownload

optional

boolean

告诉 Puppeteer 在安装过程中不要下载。

🌐 Tells Puppeteer to not download during installation.

可以被 PUPPETEER_SKIP_DOWNLOAD 覆盖。

🌐 Can be overridden by PUPPETEER_SKIP_DOWNLOAD.

temporaryDirectory

optional

string

定义 Puppeteer 用于创建临时文件的目录。

🌐 Defines the directory to be used by Puppeteer for creating temporary files.

可以被 PUPPETEER_TMP_DIR 覆盖。

🌐 Can be overridden by PUPPETEER_TMP_DIR.

os.tmpdir()