Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sean-hill/aws-puppeteer-lambda
Tooling that allows puppeteer v1.4.0 to run within the AWS Lambda environment.
https://github.com/sean-hill/aws-puppeteer-lambda
Last synced: 3 months ago
JSON representation
Tooling that allows puppeteer v1.4.0 to run within the AWS Lambda environment.
- Host: GitHub
- URL: https://github.com/sean-hill/aws-puppeteer-lambda
- Owner: sean-hill
- Created: 2018-05-04T22:55:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-24T18:08:02.000Z (over 6 years ago)
- Last Synced: 2024-09-30T17:03:34.703Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 79.7 MB
- Stars: 38
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Puppeteer Lambda
Execute [puppeteer](https://github.com/GoogleChrome/puppeteer) scripts within the AWS Lambda environment.
## Usage
```js
const puppeteer = require('puppeteer')
const { extract, cleanup } = require('aws-puppeteer-lambda');(async () => {
// Extract the headless chrome executable and return its path.
// If a previous Lambda invocation has extracted the executable, it will be reused.
const executablePath = await extract()
// Initialize a new browser instance with puppeteer to execute within Lambda.
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
args: [
'--disable-dev-shm-usage',
'--disable-gpu',
'--single-process',
'--no-zygote',
'--no-sandbox'
],
executablePath
})
// Run puppeteer script
const page = await browser.newPage()
await page.goto('https://example.com')
await page.screenshot({path: 'example.png'})
await browser.close()
// Cleanup the TMP folder after each execution otherwise Chromium's
// garbage will cause the Lambda container to run out of space.
await cleanup()
})()
```## Test
```sh
$ npm test
```