puppeteer/examples
Andrey Lushnikov d68033aeca
chore(examples): indent all examples (#1783)
Indented examples are easier to read.
2018-01-11 13:42:01 -08:00
..
block-images.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
custom-event.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
detect-sniff.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
pdf.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
proxy.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
README.md docs: fix typos (#1647) 2017-12-27 20:04:11 -07:00
screenshot-fullpage.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
screenshot.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00
search.js chore(examples): indent all examples (#1783) 2018-01-11 13:42:01 -08:00

Running the examples

Assuming you have a checkout of the Puppeteer repo and have run yarn (or npm i) to install the dependencies, the examples can be run from the root folder like so:

NODE_PATH=../ node examples/search.js

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.

Testing