Puppeteer Guide
Puppeteer is one of the most popular automation libraries, with over 85k stars on Github.
Getting Started with a New Project
To begin, install Puppeteer
1
npm install puppeteer-core
Use puppeteer.connect
method to connect to your remote browser. Here's an example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import puppeteer from 'puppeteer-core'; (async () => { const rebrowserParams = { apiKey: 'YOUR_API_KEY', } const browser = await puppeteer.connect({ browserWSEndpoint: `wss://ws.rebrowser.net/?${new URLSearchParams(rebrowserParams)}`, }) const page = await browser.newPage() await page.goto('https://rebrowser.net') await page.close() await browser.close() })().catch((error) => console.error(error.message))
Now you can visit Dashboard / Runs and see the results of your run.
Make sure to replace YOUR_API_KEY with your actual API key.
You can read more about all parameters to start a new run on Documentation / API / startRun.
Updating Your Existing Code
If you have an existing codebase working with Puppeteer, it's super easy to modify it to start leveraging a remote browser instead.
Without Rebrowser
1 2 3 4 5
import puppeteer from 'puppeteer' const browser = await puppeteer.launch() const page = await browser.newPage() // ...
With Rebrowser
1 2 3 4 5 6 7 8 9 10
import puppeteer from 'puppeteer' const rebrowserParams = { apiKey: 'YOUR_API_KEY', } const browser = await puppeteer.connect({ browserWSEndpoint: `wss://ws.rebrowser.net/?${new URLSearchParams(rebrowserParams)}`, }) const page = await browser.newPage() // ...
Fix The Leaks!
We highly encourage every customer to do some extra steps to fix all automation leaks.
You can read more on this page: Documentation / Stealth & Automation Detection