📅  最后修改于: 2023-12-03 14:41:43.053000             🧑  作者: Mango
If you're building a node.js app that requires web scraping or automation, you're probably familiar with Puppeteer. Puppeteer is a powerful, headless browser API that can do anything a regular browser can do, including generating screenshots, PDFs, and even scraping data from websites.
However, Puppeteer requires a Chromium browser to be installed on the machine running the code. This means that if you want to run Puppeteer on Heroku or another cloud platform, you'll need to manually install Chromium or use a third-party buildpack.
That's where the Heroku Puppeteer Buildpack comes in. This buildpack automates the process of installing Chromium and configuring Puppeteer on your Heroku dyno.
To use the Heroku Puppeteer Buildpack, you'll need to add it to your app as a buildpack. You can do this using the Heroku CLI or the Heroku Dashboard.
heroku buildpacks:add jontewks/puppeteer
jontewks/puppeteer
in the search bar and select itThat's it! The next time you deploy your app, the Heroku Puppeteer Buildpack will automatically install Chromium and configure Puppeteer.
By default, the Heroku Puppeteer Buildpack installs the latest version of Chromium and Puppeteer. However, you can configure the buildpack to use a specific version if necessary.
To do this, you'll need to set the PUPPETEER_VERSION
and/or CHROMIUM_VERSION
environment variables in your Heroku app. For example, to use Puppeteer version 5.5.0 and Chromium version 93.0.4577.82, you would set the following environment variables:
heroku config:set PUPPETEER_VERSION=5.5.0
heroku config:set CHROMIUM_VERSION=93.0.4577.82
The Heroku Puppeteer Buildpack makes it easy to use Puppeteer on Heroku and other cloud platforms. With just a few simple steps, you can automate web scraping, generate screenshots and PDFs, and more. Give it a try and let us know what you think!