Skip to main content
Patchright is a patched Playwright that closes the automation leaks anti-bot scripts look for. The API is the same; only the package and the import change. It connects to a Surfsky browser over the session’s CDP WebSocket URL, like Playwright. rebrowser-playwright is the other maintained fork. To have a coding agent set this up in your project, give it the setup prompt.
Use human-emulation commands for clicks, typing, and scrolling. Keep Patchright for navigation, selectors, waiting, and page content.

Prerequisites

Set your API token and base URL. The browser runs in Surfsky’s cloud, so skip the fork’s browser download step. Proxy, fingerprint, and other start options are in the API reference.

Run an example

The examples use a one-time profile. To reuse a saved login, pass a persistent profile UUID to the session call instead.
Requires Python 3.12 or newer.
Save as surfsky_patchright.py:
Run it:
Expected output:
The session scope stops the browser when it exits, including on errors. browser.close() over CDP only disconnects.