📅  最后修改于: 2022-03-11 15:03:51.657000             🧑  作者: Mango
const chromium = require('chrome-aws-lambda'); exports.handler = async (event, context, callback) => { let result = null; let browser = null; try { browser = await chromium.puppeteer.launch({ args: chromium.args, defaultViewport: chromium.defaultViewport, executablePath: await chromium.executablePath, headless: chromium.headless, ignoreHTTPSErrors: true, }); let page = await browser.newPage(); await page.goto(event.url || 'https://example.com'); result = await page.title(); } catch (error) { return callback(error); } finally { if (browser !== null) { await browser.close(); } } return callback(null, result);};