@browserless/cli

中文文档
14.1.8发布于 2026/11/08MIT近 30 天下载 4394

Command-line interface for headless browser automation. Take screenshots, generate PDFs, and extract content from websites.

原始使用文档
文档目录8 节
  1. Install
  2. About
  3. What this package does
  4. Available commands
  5. Exec examples
  6. Capture examples
  7. How it fits in the monorepo
  8. License
browserless browserless

Powered by microlink.io Last version Coverage Status NPM Status

@browserless/cli: CLI to interact with Browserless capabilities.

See the CLI section on our website for more information.

Install

Using npm:

npm install @browserless/cli -g

About

This package provides a command-line interface for interacting with browserless capabilities directly from your terminal. It exposes the browserless binary that wraps the core browserless API into easy-to-use shell commands.

What this package does

The @browserless/cli package allows you to:

  • Take screenshots from URLs with gradient backgrounds, browser overlays, and device emulation
  • Record captures as video/audio using the tabCapture extension flow
  • Generate PDFs from web pages
  • Extract content as HTML or plain text
  • Run Lighthouse audits for performance analysis
  • Analyze page weight (network requests, transfer size, resource size)
  • Check URL status and response information (redirects, headers, status codes)

Available commands

CommandDescription
capture <url>Record a page and return video buffer (use --path to save file)
screenshot <url>Capture a screenshot with optional overlay and background
pdf <url>Generate a PDF document from a web page
html <url>Serialize the page content to HTML
text <url>Extract plain text content from the page
lighthouse <url>Run a Google Lighthouse audit and output JSON report
page-weight <url>Analyze network requests, resource sizes, and basic load timings
ping <url>Get response info: status code, redirects, headers
status <url>Get the HTTP status code
goto <url>Navigate to a URL and return page/response info
exec <file>Run a script file against a new page and print what it returns

Exec examples

exec takes a file instead of a URL. The file exports a function (CommonJS module.exports or ES module export default). The CLI opens a page and calls the function with { page, browserless, opts }:

  • page: a new Puppeteer page in a fresh browser context.
  • browserless: the browserless context, for browserless.goto(page, { url }) and the rest of the API.
  • opts: the command-line flags, plus the CLI default codeScheme. --headless and --verbose are consumed by the CLI and not passed. --timeout is passed and also sets the browser timeout.
// title.js
module.exports = async ({ page, browserless, opts }) => {
  await browserless.goto(page, { url: opts.url })
  return { title: await page.title() }
}
browserless exec title.js --url=https://example.com

The file path resolves from the current directory. A returned string is printed as is and any other value as indented JSON. undefined and binary values (buffers and typed arrays, such as the result of page.screenshot()) print nothing, so write binary output to a file from the script. The file is checked before the browser starts. A thrown error is printed and the process exits with code 1.

Capture examples

# mp4 (default)
browserless capture https://example.com --path=./capture.mp4

# webm output type
browserless capture https://example.com --type=webm --path=./capture.webm

Note: The lighthouse command requires an extra installation.

Please make sure to install the standalone package by running:
npm install -g @browserless/lighthouse

How it fits in the monorepo

This package depends on:

DependencyPurpose
@browserless/captureExtension-based tab capture for CLI video recording
browserlessCore API for all browser automation operations
@browserless/lighthouseLighthouse audit integration (used by lighthouse command)

The CLI acts as a thin wrapper that parses command-line arguments, initializes a browserless instance, and delegates to the appropriate command handler.

License

@browserless/cli © Microlink, released under the MIT License.
Authored and maintained by Microlink with help from contributors.

The logo has been designed by xinh studio.

microlink.io · GitHub microlinkhq · X @microlinkhq

版本与发布记录

@browserless/cli 共发布 478 个版本,首次发布于 2020/06/21;过去 12 个月发布了 129 个版本。

版本发布日期距今
14.1.8latest2026/11/08今天
14.1.72026/11/071 天前
14.1.62026/11/071 天前
14.1.52026/11/062 天前
14.1.42026/11/062 天前
14.1.32026/11/045 天前

关于 @browserless/cli 的常见问题

@browserless/cli 是什么?

Command-line interface for headless browser automation. Take screenshots, generate PDFs, and extract content from websites.

如何安装 @browserless/cli?

在项目目录运行 npm install @browserless/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 browserless,可以用 npx browserless 直接运行。

@browserless/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/browserless__cli 是否存在。

@browserless/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@browserless/cli 可以商用吗?

@browserless/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@browserless/cli 的下载量有多少?

根据 npm 官方下载统计,@browserless/cli 在 2026/10/09 – 2026/11/07 这 30 天内被下载 4,394 次,日均约 146 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@browserless/cli 还在维护吗?

最新版本 14.1.8 发布于 2026/11/08(今天);至今共发布 478 个版本,其中过去 12 个月发布了 129 个;首次发布于 2020/06/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。