How to use the chrome-aws-lambda.executablePath 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.

github netlify-labs / netlify-functions-headless-chrome / functions / chrome / chrome.js View on Github external
exports.handler = async (event, context, callback) => {
  let theTitle = null
  let browser = null
  console.log('spawning chrome headless')
  try {
    const executablePath = await chromium.executablePath

    // setup
    browser = await puppeteer.launch({
      args: chromium.args,
      executablePath: executablePath,
      headless: chromium.headless,
    })

    // Do stuff with headless chrome
    const page = await browser.newPage()
    const targetUrl = 'https://davidwells.io'

    // Goto page and then do stuff
    await page.goto(targetUrl, {
      waitUntil: ["domcontentloaded", "networkidle0"]
    })
github cheeaun / puppetron / index.js View on Github external
let actionDone = false;
    const width = parseInt(searchParams.get('width'), 10) || 1024;
    const height = parseInt(searchParams.get('height'), 10) || 768;

    page = cache.get(pageURL);
    if (!page) {
      if (!browser) {
        console.log('🚀 Launch browser!');
        const config = {
          ...(isDev ? {
            // executablePath: '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
            executablePath: findChrome(),
          } : {
            args: chrome.args,
            executablePath: await chrome.executablePath,
            headless: chrome.headless,
          }),
        };
        browser = await puppeteer.launch(config);
      }
      page = await browser.newPage();

      const nowTime = +new Date();
      let reqCount = 0;
      await page.setRequestInterception(true);
      page.on('request', (request) => {
        const url = request.url();
        const method = request.method();
        const resourceType = request.resourceType();

        // Skip data URIs
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 bartveneman / extract-css / _chromium.js View on Github external
async function getOptions() {
	if (isDev) {
		return {
			args: [],
			executablePath: exePath,
			headless: true
		}
	}

	return {
		args: chrome.args,
		executablePath: await chrome.executablePath,
		headless: chrome.headless
	}
}
github luisfarzati / chromda / src / captureScreenshot.js View on Github external
* @property {"page"|"viewport"|"element"} [capture]
 * @property {PuppeteerOptions} [puppeteer]
 * @property {string[]} [exclude]
 * @property {string} [selector]
 * @property {PuppeteerStyleTagOptions[]} [styles]
 */

const defaultViewport = {
  width: VIEWPORT_WIDTH,
  height: VIEWPORT_HEIGHT,
  deviceScaleFactor: DEVICE_SCALE_FACTOR,
  isMobile: IS_MOBILE,
  isLandscape: IS_LANDSCAPE
};

const puppetshot = chromeLambda.executablePath.then(
  executablePath =>
    new MrPuppetshot(
      {
        executablePath,
        args: [...chromeLambda.args, ...CHROMIUM_ARGS],
        headless: true,
        defaultViewport,
        ignoreHTTPSErrors: IGNORE_HTTPS_ERRORS,
        timeout: TIMEOUT
      },
      chromeLambda.puppeteer
    )
);

/**
 * @type {import('aws-lambda').Handler}
github sthobis / site-palette / api / get-palette.js View on Github external
const getOptions = async () => {
  return process.env.NOW_REGION === "dev1"
    ? {
        args: [],
        executablePath: exePath,
        headless: true,
    }
    : {
      args: chrome.args,
      executablePath: await chrome.executablePath,
      headless: chrome.headless
    }
}
github oblador / loki / packages / renderer-aws-lambda / src / create-aws-lambda-renderer.js View on Github external
const createChromeAWSLambdaRenderer = () => async event => {
  const command = commands[event.command];
  if (!command) {
    throw serializeError(new Error(`Unknown command "${event.command}"`));
  }
  const target = createChromeAppTarget({
    baseUrl: event.baseUrl,
  });
  try {
    await target.start({
      chromeFlags: chromium.args,
      chromePath: await chromium.executablePath,
    });
    return await command(target, event);
  } catch (error) {
    throw serializeError(unwrapError(error));
  } finally {
    await target.stop();
  }
};
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' }
	);

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

	await browser.close();
github styfle / screenshot-v2 / chromium.js View on Github external
async function getScreenshot(url, type, quality, fullPage) {
    const browser = await puppeteer.launch({
        args: chrome.args,
        executablePath: await chrome.executablePath,
        headless: chrome.headless,
    });

    const page = await browser.newPage();
    await page.goto(url);
    const file = await page.screenshot({ type,  quality, fullPage });
    await browser.close();
    return file;
}
github iann0036 / amazon-connect-cfn / lambda / index.js View on Github external
return macro_response;
    } else {
        var response_object = {
            "Status": "SUCCESS",
            "PhysicalResourceId": event.LogicalResourceId,
            "StackId": event.StackId,
            "RequestId": event.RequestId,
            "LogicalResourceId": event.LogicalResourceId,
            "Data": {}
        };

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

            let page = await browser.newPage();

            if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_Instance") {
                await login(page);
                response_object.Data = await createinstance(page, event.ResourceProperties);
            } else if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_ContactFlow") {
                await login(page);
                await open(page, event.ResourceProperties);
                response_object.Data = await createflow(page, event.ResourceProperties);
            } else if (event.RequestType == "Create" && event.ResourceType == "Custom::AWS_Connect_PhoneNumber") {
                await login(page);
                await open(page, event.ResourceProperties);
                response_object.Data = await claimnumber(page, event.ResourceProperties);

chrome-aws-lambda

Chromium Binary for AWS Lambda and Google Cloud Functions

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis