3.0 KiB
3.0 KiB
Running the examples
Assuming you have a checkout of the Puppeteer repo and have run npm i (or yarn) to install the dependencies, the examples can be run from the root folder like so:
NODE_PATH=../ node examples/search.js
Larger examples
More complex and use case driven examples can be found at github.com/GoogleChromeLabs/puppeteer-examples.
Tips & Tricks
Load a Chrome extension
By default, Puppeteer disables extensions when launching Chrome. You can load a specific extension using:
const browser = await puppeteer.launch({
headless: false,
args: [
'--disable-extensions-except=/path/to/extension/',
'--load-extension=/path/to/extension/',
]
});
Other resources
Other useful tools, articles, and projects that use Puppeteer.
Rendering and web scraping
- Puppetron - Demo site that shows how to use Puppeteer and Headless Chrome to render pages. Inspired by GoogleChrome/rendertron.
- Thal - Getting started with Puppeteer and Chrome Headless for Web Scraping.
- 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 - Crawler that provides simple APIs to manipulate Headless Chrome and allows you to crawl dynamic websites.
- puppeteer-examples - Puppeteer Headless Chrome examples for real life use cases such as getting useful info from the web pages or common login scenarios.
- browserless - Headless Chrome as a service letting you execute Puppeteer scripts remotely. Provides a docker image with configuration for concurrency, launch arguments and more.
- Puppeteer Sandbox - Puppeteer sandbox environment as a service. Runs Puppeteer scripts and allows saving and embedding them in external sites and markdown files.
Testing
- angular-puppeteer-demo - Demo repository explaining how to use Puppeteer in Karma.
- mocha-headless-chrome - Tool which runs client-side mocha tests in the command line through headless Chrome.
- puppeteer-to-istanbul-example - Demo repository demonstrating how to output Puppeteer coverage in Istanbul format.
Services
- Checkly - Monitoring SaaS that uses Puppeteer to check availability and correctness of web pages and apps.