@hackstudio/puppeteer-lambda-launcher

1.0.4 • Public • Published

Puppeteer lambda launcher

Drive Chrome headless with Pupetteer on AWS LAMBDA. This module download and install a chromium instance on AWS lambda.

npm

Contents

  1. General
  2. Installation
  3. Setup

General

This lib has been built for web scraping and automation after working 2 days on making it working on AWS lambda.

Installation

Install with npm:

npm install --save @hackstudio/puppeteer-lambda-launcher

Setup

Use in your AWS Lambda function. Requires Node 6.10.

let ChromeInstaller = require('@hackstudio/puppeteer-lambda-launcher')

ChromeInstaller = new ChromeInstaller({ 
  accessKeyId: 'AKIAxxxxxxxxxxxx', 
  secretAccessKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 
  s3Bucket:'bucket_name_xxx', s3Key:'s3_object_name', 
  executePath:'xxxxxxxxxxxxx'
})

// accessKeyId : get it from your AWS account
// secretAccessKey : get it from your AWS account
// s3Bucket : 'bucket_name' // bucket where compressed chromium is stored. You can download it here : https://github.com/Tchangang/puppeteer-lambda-launcher/releases/tag/1.0
// s3Key : 's3_object_name' // key to retrieve object on S3. Ex: headless-chromium.tar.gz
// executePath : 'headless-chromium' // Name of executable path when chromium uncompressed 

// Setup chromium
await ChromeInstaller.setupChrome()

// if chromium is not installed, we will download, decompress it and install in /tmp folder  
const chromePath = ChromeInstaller.executablePath

// Launch puppeteer

const args = [
  '--no-sandbox',
  '--disable-gpu',
  '--disable-setuid-sandbox',
  '--single-process',
  '--headless'
]
const puppeteer = require('puppeteer')
browser = await puppeteer.launch({
  headless: true,
  executablePath: chromePath
  args:args
})

// Enjoy it :-)

Thanks to https://github.com/sambaiz/puppeteer-lambda-starter-kit for his work.

Feel free to contact me at tchangang.boris+github@gmail.com :-)

Package Sidebar

Install

npm i @hackstudio/puppeteer-lambda-launcher

Weekly Downloads

5

Version

1.0.4

License

ISC

Unpacked Size

7.13 kB

Total Files

4

Last publish

Collaborators

  • hackstudio