示例和用例
¥Examples & Use cases
官方示例
¥Official examples
Puppeteer 存储库 包含由 Puppeteer 团队维护的少量示例。
¥The Puppeteer repository includes a small number of examples maintained by the Puppeteer team.
按照 README 中的说明运行示例,涵盖从网站创建 PDF、创建屏幕截图或拦截请求等用例。
¥Follow the instructions in the README to run the examples, covering use cases like creating PDFs from websites, creating screenshots or intercepting requests.
示例套件
¥Example suite
在 Puppeteer 专用的 示例存储库 中找到一组非结构化示例。
¥Find a set of unstructured examples in Puppeteer's dedicated example repository.
该套件是一系列示例,随着时间的推移不断增长,涵盖了各种用例,例如将事件从 Puppeteer 进程转发到浏览器、与元素交互以及运行 CDP 命令
¥This suite is a collection of examples that has been growing over time and covers various use cases like forwarding events from your Puppeteer process to the browser, interacting with elements and running CDP commands.
其他项目、文章和演示
¥Other projects, articles and demos
请参阅以下列表,了解渲染、Web 抓取和测试等类别的用例和示例。
¥See the following list for use cases and examples from categories like Rendering, Web scraping and Testing.
渲染和网页抓取
¥Rendering and web scraping
-
Puppetron:演示站点展示如何使用 Puppeteer 和 Headless Chrome 渲染页面。受 GoogleChrome/rendertron 启发。
¥Puppetron: Demo site that shows how to use Puppeteer and Headless Chrome to render pages. Inspired by GoogleChrome/rendertron.
-
Thal:开始使用 Puppeteer 和 Chrome Headless 进行 Web 抓取。
¥Thal: Get started with Puppeteer and Chrome Headless for Web Scraping.
-
pupperender:Express 中间件检查传入请求的 User-Agent 标头,如果它与一组可配置的机器人之一匹配,则使用 Puppeteer 渲染页面。适用于 PWA 渲染。
¥pupperender: Express middleware that checks the User-Agent header of incoming requests, and if it matches one of a configurable set of bots, render the page using Puppeteer. Useful for PWA rendering.
-
headless-chrome-crawler:提供 API 来操作 Headless Chrome 并允许你抓取动态网站的爬虫。
¥headless-chrome-crawler: Crawler that provides APIs to manipulate Headless Chrome and lets you crawl dynamic websites.
-
Checkly 的 Puppeteer 示例:用于实际用例的 E2E Puppeteer 示例,例如从网页或常见登录场景中获取有用信息。
¥Puppeteer examples from Checkly: E2E Puppeteer examples for real life use cases, such as getting useful info from the web pages or common login scenarios.
-
browserless:Headless Chrome 即服务,让你可以远程执行 Puppeteer 脚本。
¥browserless: Headless Chrome as a service letting you execute Puppeteer scripts remotely.
-
AWS Lambda 上的 Puppeteer:使用无服务器框架在 AWS Lambda 上运行 puppeteer
¥Puppeteer on AWS Lambda: Run puppeteer on AWS Lambda with Serverless framework
-
Apify SDK:可扩展的 JavaScript Web 抓取和抓取库。自动管理 Puppeteer 浏览器池并提供错误处理、任务管理、代理轮换等。
¥Apify SDK: The scalable web crawling and scraping library for JavaScript. Automatically manages a pool of Puppeteer browsers and provides error handling, task management, proxy rotation and more.
测试
¥Testing
-
angular-puppeteer-demo:演示存储库解释如何在 Karma 中使用 Puppeteer。
¥angular-puppeteer-demo: Demo repository explaining how to use Puppeteer in Karma.
-
mocha-headless-chrome:通过无头 Chrome 在命令行中运行客户端 mocha 测试的工具。
¥mocha-headless-chrome: Tool which runs client-side mocha tests in the command line through headless Chrome.
-
puppeteer-to-istanbul-example:演示存储库演示如何以伊斯坦布尔格式输出 Puppeteer 覆盖范围。
¥puppeteer-to-istanbul-example: Demo repository demonstrating how to output Puppeteer coverage in Istanbul format.
-
jest-puppeteer:(几乎)用于设置和运行 Jest 和 Puppeteer 的零配置工具。还包括 Puppeteer 的断言库。
¥jest-puppeteer: (almost) Zero configuration tool for setting up and running Jest and Puppeteer. Also includes an assertion library for Puppeteer.
-
puppeteer-har:使用 puppeteer 生成 HAR 文件。
¥puppeteer-har: Generate HAR file with puppeteer.
-
puppetry:一款桌面应用,用于构建 Puppeteer 和 Jest 驱动的测试,无需编码。
¥puppetry: A desktop app to build Puppeteer and Jest driven tests without coding.
-
puppeteer-loadtest:用于对 Puppeteer 脚本执行负载测试的命令行接口。
¥puppeteer-loadtest: command line interface for performing load test on Puppeteer scripts.
-
cucumber-puppeteer-example:示例存储库演示如何使用 Puppeeteer 和 Cucumber 进行集成测试。
¥cucumber-puppeteer-example: Example repository demonstrating how to use Puppeeteer and Cucumber for integration testing.