How to use Puppeteer to take Screenshots of Pages

2020-07-31 04:51发布

问题:

I'm currently using Puppeteer to open a site and take a screenshot of a video. However, the default Chromium browser that puppeteer runs doesn't work with video types.

I launched with a local version of Chrome with Puppeteer and everything is working.

Is there a way to open an actual chrome browser instance with puppeteer without having to specify a local link to the .exe to make it more scalable and less reliant on a directory when being hosted?

Puppeteer 2.0.0

Note: I'm running a non-chromium instance with Puppeteer (without a directory to Chrome.exe)

回答1:

You may find that Puppeteer does not behave as expected when controlling pages that incorporate audio and video. (For example, video playback/screenshots is likely to fail.) There are two reasons for this:

  • Puppeteer is bundled with Chromium — not Chrome — and so by default, it inherits all of Chromium's media-related limitations. This means that Puppeteer does not support licensed formats such as AAC or H.264. (However, it is possible to force Puppeteer to use a separately-installed version Chrome instead of Chromium via the executablePath option to puppeteer.launch. You should only use this configuration if you need an official release of Chrome that supports these media formats.)
  • Since Puppeteer (in all configurations) controls a desktop version of Chromium/Chrome, features that are only supported by the mobile version of Chrome are not supported. This means that Puppeteer does not support HTTP Live Streaming (HLS).

Source: FAQ: What features does puppeteer not support?