puppeteer
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@puppeteer/browsers | 2.0.0 | 59.09 kB | Apache-2.0 | prod | |
cosmiconfig | 9.0.0 | 28.97 kB | MIT | prod | |
puppeteer-core | 22.0.0 | 893.48 kB | Apache-2.0 | prod |
Puppeteer is a Node.js library that equips software developers with a high-level API for controlling Chrome or Chromium browsers over the DevTools Protocol. The library enables a vast array of browser automation tasks, from generating screenshots and PDFs of pages, to rendering Single-page Applications (SPAs), form submission automation, UI testing, keyboard input automation, performance testing, and even testing Chrome Extensions. One of its primary attractions is that Puppeteer operates in headless mode by default, but it can also be configured to run in a fully visible, or "headful", Chrome/Chromium mode.
Using Puppeteer requires Node.js, and the library is installed via NPM or Yarn. Here is a basic example of how you can use Puppeteer for browser automation:
npm i puppeteer
Or with Yarn:
yarn add puppeteer
After Puppeteer is installed, here is a simple usage example where Puppeteer loads a webpage and takes a screenshot:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'example.png' });
await browser.close();
})();
This block of code tells Puppeteer to launch a browser, navigate to 'https://example.com', take a screenshot, save it as 'example.png', and finally close the browser.
To customize Puppeteer's default behaviors such as cache directory or execution mode, configurations can be made when launching the browser. For more advanced use cases, check out the guides provided by Puppeteer.
Puppeteer's official documentation, as well as guides on how to use the library, frequently asked questions, and details on how to contribute, can be found on their website: Puppeteer API Docs, Guides, FAQ, and Contributing. It's a go-to resource for any developer seeking to extend their knowledge of Puppeteer and browser automation. Documentation of the latest version can also be found on the GitHub repo: git+https://github.com/puppeteer/puppeteer.git#main.