Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jupiterone/playwright-aws-lambda
Support for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions
https://github.com/jupiterone/playwright-aws-lambda
aws cloud function google lambda playwright puppeteer
Last synced: 2 days ago
JSON representation
Support for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions
- Host: GitHub
- URL: https://github.com/jupiterone/playwright-aws-lambda
- Owner: JupiterOne
- License: mit
- Created: 2020-02-12T09:37:30.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-25T19:20:45.000Z (6 months ago)
- Last Synced: 2025-01-30T14:39:43.237Z (3 days ago)
- Topics: aws, cloud, function, google, lambda, playwright, puppeteer
- Language: TypeScript
- Size: 81.5 MB
- Stars: 411
- Watchers: 15
- Forks: 53
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# playwright-aws-lambda
![CI](https://github.com/JupiterOne/playwright-aws-lambda/workflows/CI/badge.svg)
[![NPM](https://img.shields.io/npm/v/playwright-aws-lambda)](https://www.npmjs.com/package/playwright-aws-lambda)Support for Playwright running on AWS Lambda and Google Cloud Functions.
**NOTE**: Currently only Chromium is supported.
## Install
```shell
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.```javascript
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}` | Launches the Chromium browser. |
| `loadFont(url)` | `{Promise}` | 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.```js
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](https://github.com/alixaxel/chrome-aws-lambda).