How to use the chrome-aws-lambda.puppeteer function in chrome-aws-lambda

To help you get started, we’ve selected a few chrome-aws-lambda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensult / cloud-reports / src / reporters / pdf / index.ts View on Github external
const getPuppeteer = async () => {
    try {
        const puppeteer = require('puppeteer');
        return await puppeteer.launch();
    } catch (error) {
        if (error.code === 'MODULE_NOT_FOUND') {
            console.log('Error(This package is used for local development) ', JSON.stringify(error, null, 2));
            try {
                const chromium = require('chrome-aws-lambda')
                return await chromium.puppeteer.launch({
                    args: chromium.args,
                    defaultViewport: chromium.defaultViewport,
                    executablePath: await chromium.executablePath,
                    headless: chromium.headless
                });
            } catch (_error) {
                throw error;
            }
        }
    }
}
github ireade / caniuse-embed / functions / screenshot / screenshot.js View on Github external
const takeScreenshot = async (feature, periods, accessibleColours) => {

  const browser = await chromium.puppeteer.launch({
    args: chromium.args,
    defaultViewport: {
        width: 800,
        height: 600,
        isLandscape: true
    },
    executablePath: await chromium.executablePath,
    headless: chromium.headless,
  });

	const page = await browser.newPage();

	await page.goto(
		`https://caniuse.bitsofco.de/embed/index.html?feat=${feature}&periods=${periods}&accessible-colours=${accessibleColours}&screenshot=true`,
		{ waitUntil: 'networkidle2' }
	);
github tophat / sanity-runner / service / src / jestSetup / puppeteer / setup.js View on Github external
module.exports = async () => {
    const config = {
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
    }
    const browser = await chromium.puppeteer.launch(config)
    global.__BROWSER__ = browser
    await fs.mkdirs(DIR)
    await fs.writeFile(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint())
}
github luisfarzati / chromda / src / captureScreenshot.js View on Github external
executablePath =>
    new MrPuppetshot(
      {
        executablePath,
        args: [...chromeLambda.args, ...CHROMIUM_ARGS],
        headless: true,
        defaultViewport,
        ignoreHTTPSErrors: IGNORE_HTTPS_ERRORS,
        timeout: TIMEOUT
      },
      chromeLambda.puppeteer
    )
);
github tophat / sanity-runner / service / src / jestSetup / puppeteer / environment.js View on Github external
async setup() {
        await super.setup()
        const wsEndpoint = await fs.readFile(wsEndpointDir, 'utf8')
        if (!wsEndpoint) throw new Error('wsEndpoint not found')
        this.global.browser = await chromium.puppeteer.connect({
            browserWSEndpoint: wsEndpoint,
        })
    }
github ireade / netlify-puppeteer-screenshot-demo / functions / take-screenshot / take-screenshot.js View on Github external
exports.handler = async (event, context) => {

    const pageToScreenshot = JSON.parse(event.body).pageToScreenshot;

    if (!pageToScreenshot) return {
        statusCode: 400,
        body: JSON.stringify({ message: 'Page URL not defined' })
    }

    const browser = await chromium.puppeteer.launch({
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        executablePath: await chromium.executablePath,
        headless: chromium.headless,
    });
    
    const page = await browser.newPage();

    await page.goto(pageToScreenshot, { waitUntil: 'networkidle2' });

    const screenshot = await page.screenshot({ encoding: 'binary' });

    await browser.close();
  
    return {
        statusCode: 200,

chrome-aws-lambda

Chromium Binary for AWS Lambda and Google Cloud Functions

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis