Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arthurweinmann/puppeteer-server
Run Puppeteer (browser automation) as a HTTP API
https://github.com/arthurweinmann/puppeteer-server
api puppeteer rpc
Last synced: 6 days ago
JSON representation
Run Puppeteer (browser automation) as a HTTP API
- Host: GitHub
- URL: https://github.com/arthurweinmann/puppeteer-server
- Owner: arthurweinmann
- Created: 2024-01-22T17:55:51.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-01-29T11:22:33.000Z (10 months ago)
- Last Synced: 2024-05-02T04:20:25.399Z (7 months ago)
- Topics: api, puppeteer, rpc
- Language: JavaScript
- Homepage:
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Puppeteer Pseudo-RPC HTTP server
Make Puppeteer accessible through a simple HTTP server. This allows you to use headless chrome and also puppeteer from other programming languages without suffering from the cold start cost each time.
# Warning
This server is probably not safe to expose directly to users on the web. It should be behind a trusted web server implemented in another programming language, and only accessible from the machine it is running on or from a VPN.
# How to use
Clone this repository or download the zip in the release section.
Start the server with:
```sh
bun run server.js --homedir=/path/to/home/directory --verbose --listenon=10.0.0.2 --port=8085 --maxbrowsers=1 --launchargs='["--no-sandbox", "--disable-gpu", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]'
```Access your new and shiny constantly ready pool of puppeteers:
```bash
curl -X POST http://127.0.0.1:8085/puppeteer_pseudo_rpc \
-H "Content-Type: application/json" \
-d @- << EOF
{
returnvariables: ["names of a variable you defined in calls and would like to return in the response"],
calls: [
{
targetvarname: "the name of the variable into which to save the result of the method call, for example page",
methodreceiver: "previously created variable name" | "startingpage" | "browser"
methodname: "for example screenshot",
parameters: [{path: "screenshot.png"}, "#varname: start a string with # to replace it by the value of a previously defined variable"],
}
]
}
EOF
```Response Example:
```
{
success: true,
variables: {
"varname": "variable value",
},
}
```