aws-puppeteer-lambda
Execute puppeteer scripts within the AWS Lambda environment.
Last updated 2 years ago by sean-hill .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aws-puppeteer-lambda 
SYNC missed versions from official npm registry.

Puppeteer Lambda

Execute puppeteer scripts within the AWS Lambda environment.

Usage

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

$ npm test

Current Tags

  • 1.0.2                                ...           latest (2 years ago)

3 Versions

  • 1.0.2                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |