bautaDocs

Python and Node.js Packages

Launch a persona from Python or Node.js with the bautabrowser packages.

The bautabrowser packages launch a persona from your code. launch() reaches the gateway on this machine, or starts it, makes the persona and connects over CDP; the rest of your Playwright or Puppeteer code is unchanged.

Install

pip install bautabrowser
npm install bautabrowser playwright-core      # or puppeteer-core

The first launch() downloads bauta into ~/.bauta/bin, checked against the release's signed SHA256SUMS. On a terminal it then runs bauta setup to offer a free account; without a terminal it activates the free plan (one session).

To use a bauta you already have, set BAUTA_BIN. Or install it yourself:

curl -fsSL https://bauta.dev/install.sh | bash

Launch

from bautabrowser import launch

browser = launch(proxy="http://user:pass@host:port", humanize=True)
page = browser.new_page()
page.goto("https://example.com")
browser.close()
const { launch } = require("bautabrowser");      // import { launch } from "bautabrowser" works too

const browser = await launch({ proxy: "http://user:pass@host:port", humanize: true });
const page = await browser.newPage();
await page.goto("https://example.com");
await browser.close();

launch() returns a Playwright Browser on a persona. From bautabrowser/puppeteer it resolves to a Puppeteer Browser instead, with the same options (Connecting Puppeteer).

Choose the device

By default a launch uses a desktop device drawn from bauta's built-in pool; --fingerprint-platform=macos in args asks for a macOS one. Or pass persona: a built-in persona's name or a persona file.

browser = launch(args=["--fingerprint-platform=macos"])   # a macOS device from the pool
browser = launch(persona="win-intel")                      # a built-in persona
browser = launch(persona="/abs/path/shop.json")            # a persona file

Keep an identity

A launch without name gets a fresh identity that keeps nothing. With a name, or --fingerprint=12345 in args, it is the same identity, the same device, on every launch:

browser = launch(name="shop")
browser = launch(args=["--fingerprint=12345"])

Keep cookies and storage

launch_persistent_context (in Node.js, launchPersistentContext) returns the persona's BrowserContext, with its cookies and storage kept between launches:

from bautabrowser import launch_persistent_context

context = launch_persistent_context("shop", humanize=True)
page = context.new_page()
page.goto("https://example.com")
context.close()
const { launchPersistentContext } = require("bautabrowser");

const context = await launchPersistentContext("shop", { humanize: true });
const page = await context.newPage();
await page.goto("https://example.com");
await context.close();

With Puppeteer, use launch({ name: "shop", ephemeral: false }).

Async Python

launch_async and launch_persistent_context_async are the same, for Playwright's async API:

import asyncio
from bautabrowser import launch_async

async def main():
    browser = await launch_async(humanize=True)
    page = await browser.new_page()
    await page.goto("https://example.com")
    await browser.close()

asyncio.run(main())

Options

PythonNode.jswhat it does
personapersonaA built-in persona's name or a persona file. Without it, a desktop device from bauta's built-in pool.
namenameThe same identity, the same device, on every launch. Without it, a fresh identity that keeps nothing.
argsargs--fingerprint-platform=macos draws a macOS device from the pool; --fingerprint=12345 keeps one identity, as name does.
proxyproxyThe persona's proxy, such as http://user:pass@host:port (Using a proxy).
timezone, localetimezone, localeThe persona's timezone and locale. With a proxy, they follow where the proxy exits unless you give both.
humanizehumanizeClicks and typing move as a hand does.
requestsrequestsRequest rules that spend fewer of a proxy's bytes (Saving proxy bandwidth).
block_third_party_cookiesblockThirdPartyCookiesThird-party cookies blocked, as for a person who chose "Block third-party cookies" in Chrome's settings. Otherwise they are allowed, Chrome's default.
headlessheadlessOn (the default), the gateway's windows stay on a virtual display; off, they open on your display. It applies when the call starts the gateway.
gatewaygatewayA gateway that runs elsewhere, such as a container's: http://127.0.0.1:9222. You make its personas there.
extension_pathsextensionPathsUnpacked extensions the persona's browser loads. Such a persona has a browser of its own.
pluginpluginA native plugin that every page of the persona runs (Native plugins).

Get a persona's endpoint

endpoint(...) returns the persona's CDP URL, for another CDP client:

from bautabrowser import endpoint

url = endpoint(name="shop")
const { endpoint } = require("bautabrowser");

const url = await endpoint({ name: "shop" });

Environment variables

variablewhat it does
BAUTA_BINA bauta you already have, for the packages to use.
BAUTA_GATEWAYA gateway that runs elsewhere, as the gateway option.

Next

On this page