项目
在 GitHub 查看
JupiterOne/playwright-aws-lambda
关于
支持在 AWS Lambda 和 Google Cloud Functions 上运行 Microsoft Playwright。
其他项目实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文playwright-aws-lambda
Support for Playwright running on AWS Lambda and Google Cloud Functions.
NOTE: Currently only Chromium is supported.
Install
npm install playwright-core playwright-aws-lambda --save
Usage
This package works with the nodejs10.x, nodejs12.x, nodejs14.x, nodejs16.x, nodejs18.x and nodejs20.x AWS Lambda runtimes
out of the box.
const playwright = require('playwright-aws-lambda');
exports.handler = async (event, context) => {
let browser = null;
try {
browser = await playwright.launchChromium();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(event.url || 'https://example.com');
console.log('Page title: ', await page.title());
} catch (error) {
throw error;
} finally {
if (browser) {
await browser.close();
}
}
};
API
| Method / Property | Returns | Description |
|---|---|---|
launchChromium |
{!Promise<playwright.ChromiumBrowser>} |
Launches the Chromium browser. |
loadFont(url) |
{Promise<void>} |
Downloads and activates a custom font |
Loading additional fonts
If you need custom font support by e.g. emojicons in your browser, you have to
load it by using the loadFont(url: string) function before you launch the
browser.
await loadFont(
'https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf'
);
Thanks / Credits
This project is based on the work of chrome-aws-lambda.
探索相关项目
加载中…