Puppeteer is a Node.js library which provides a high-level API to control Chrome or Chromium browsers over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium. Therefore, the primary programming language used with Puppeteer is JavaScript (or TypeScript, which is a superset of JavaScript).
Here is an example of how to use Puppeteer with JavaScript:
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 script tells the browser to go to https://example.com
and then take a screenshot. The screenshot is saved in the same directory as example.png
.
In summary, Puppeteer is primarily used with JavaScript or TypeScript because it is a Node.js library.