@hackstudio/puppeteer-lambda-launcher
v1.0.4
Published
Launch chromium on AWS lambda and use it with Puppeteer
Downloads
25
Maintainers
Readme
Puppeteer lambda launcher
Drive Chrome headless with Pupetteer on AWS LAMBDA. This module download and install a chromium instance on AWS lambda.
Contents
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 [email protected] :-)