Skip to content

Commit

Permalink
Moved from deno to bun, because bun supports the nodejs puppeteer wit…
Browse files Browse the repository at this point in the history
…hout alterations
  • Loading branch information
arthurweinmann committed Jan 26, 2024
1 parent 833890e commit 5ff223a
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 201 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v3

- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.39.x

- name: Deno compile CLI
run: |
deno compile --unstable --allow-read --allow-run --allow-write --allow-net --allow-env --output=puppeteerserver server.js
- name: Tar out folder
working-directory: ./
run: tar -czvf puppeteer_server.tar.gz --exclude=.github ./*

- name: Get current date
id: date
Expand All @@ -33,7 +28,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete latest-release --yes || true
gh release create latest-release puppeteerserver \
gh release create latest-release puppeteer_server.tar.gz \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} latest release" \
--notes "Generated on ${{ steps.date.outputs.date }}"
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ This server is probably not safe to expose directly to users on the web. It shou

# How to use

Build the binary yourself by following [.github/workflows/release.yml](.github/workflows/release.yml) locally or by forking this repository.
You can also download the binary file already compiled in the release section of this repository.
Clone this repository or download the zip in the release section.

Run it, give it the address and port it will listen to, and also the maximum number of headless chrome to start:
`./puppeteerserver --listenon 127.0.0.1 --port 8085 --maxbrowsers 3`
Start the server with:
```sh
bun run server.js --homedir=/path/to/home/directory --verbose --listenon=10.0.0.2 --port=8085 --maxbrowsers=1
```

Finally, access your new and shiny constantly ready pool of puppeteers:
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" \
Expand All @@ -26,7 +27,7 @@ curl -X POST http://127.0.0.1:8085/puppeteer_pseudo_rpc \
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 a previously defined variable holds"],
parameters: [{path: "screenshot.png"}, "#varname: start a string with # to replace it by the value of a previously defined variable"],
}
]
}
Expand All @@ -42,7 +43,3 @@ Response Example:
},
}
```

# Tip

You may need to run `PUPPETEER_PRODUCT=chrome /root/.deno/bin/deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts` in order to install the version of chrome supported by the version of Deno puppeteer
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "quickstart",
"module": "server.js",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"path": "^0.12.7",
"puppeteer": "^21.9.0"
}
}
Loading

0 comments on commit 5ff223a

Please sign in to comment.