Skip to main content
Version: 23.8.0

什么是 Puppeteer?

¥What is Puppeteer?

Puppeteer 是一个 JavaScript 库,它提供了一个高级 API 来通过 开发工具协议WebDriver 双向 控制 Chrome 或 Firefox。Puppeteer 默认在无头(无可见 UI)浏览器中运行,但可以配置为在可见("有头")浏览器中运行。

¥Puppeteer is a JavaScript library which provides a high-level API to control Chrome or Firefox over the DevTools Protocol or WebDriver BiDi. Puppeteer runs in the headless (no visible UI) by default but can be configured to run in a visible ("headful") browser.

特性

¥Features

你可以在浏览器中手动执行的大多数操作都可以使用 Puppeteer 完成!以下是一些帮助你入门的示例:

¥Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:

  • 自动化表单提交、UI 测试、键盘输入等。

    ¥Automate form submission, UI testing, keyboard input, etc.

  • 使用最新的 JavaScript 和浏览器功能创建自动化测试环境。

    ¥Create an automated testing environment using the latest JavaScript and browser features.

  • 捕获站点的 时间线痕迹 以帮助诊断性能问题。

    ¥Capture a timeline trace of your site to help diagnose performance issues.

  • 测试 Chrome 扩展程序

    ¥Test Chrome Extensions.

  • 生成页面的屏幕截图和 PDF。

    ¥Generate screenshots and PDFs of pages.

  • 抓取 SPA(单页应用)并生成预渲染内容(即 "SSR"(服务器端渲染))。

    ¥Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)).