Does your company rely on browser automation or web scraping? We have a wild offer for our early customers! Read more →

Other Libraries Guide

Rebrowser works with any library that controls a browser using CDP (Chrome DevTools Protocol). Most automation libraries use this protocol to send commands to the browser.

The main change you need to make is to find out how to pass a devtools URL to your chosen library, and use the Rebrowser start run URL instead of your local browser.

In most cases, you'll need to replace http://localhost:9222 with wss://ws.rebrowser.net/?apiKey=YOUR_API_KEY.

chromedp

There's an example in the chromedp repo showing how to use it with a remote browser.

You can use this example, just change -url ws://127.0.0.1:9222 to the Rebrowser URL with your API key.

chrome-remote-interface

chrome-remote-interface is quite popular library to work with raw CDP, but it's a bit tricky to use with a remote browser. If you just pass the same url to websocket like you do when you use Puppeteer or Playwright, you will get an error Page.enable wasn't found or similar. It happens because it expects URL to the specific page session rather than to a browser session. Here are the steps how to fix it.

First, you need to start a browser session using startRun command. Then you need to pick run.cdpEndpoints.list from the response and request this URL manually, it will return you a list of open pages, something like this:

1
2
3
4
5
6
7
8
9
10
11
12
[
  {
    "description": "",
    "devtoolsFrontendUrl": "",
    "id": "...",
    "title": "rebrowser-bot-detector",
    "type": "page",
    "url": "https://bot-detector.rebrowser.net/",
    "webSocketDebuggerUrl": "wss://ws.rebrowser.net/cdp/devtools/page/..."
  },
  ...
]

Then you need to use webSocketDebuggerUrl and pass it to chrome-remote-interface like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
import CDP from 'chrome-remote-interface'
const options = {
  target: 'wss://ws.rebrowser.net/cdp/devtools/page/...',
  useHostName: true,
  port: 443,
  secure: true,
}
CDP(options, (client) => {
  console.log('Connected!')
  client.close()
}).on('error', (err) => {
  console.error(err)
})

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