Skip to main content

Python client for Agent Controlled Browser

Project description

ACOB Python Client

The ACOB Python client controls one Chromium installation through an ACOB server. It uses only the Python standard library.

Install it from the repository:

pip install ./client

Create a client with the browser ID shown in the extension popup. The endpoint defaults to http://127.0.0.1:58347:

from pathlib import Path

from acob import ACOBClient

client = ACOBClient("0123456789ab4def8123456789abcdef")

tabs = client.tabs(operation="list")
tab = client.tabs(operation="navigate", url="https://example.com")
tid = tab["tid"]

client.click(tid, "a")
client.keyboard(tid, text="ACOB")
client.keyboard(tid, key="Enter")
title = client.javascript(tid, "document.title")

capture = client.screenshot(tid, full_page=True)
png = client.download_screenshot(capture["download_url"])
Path("screenshot.png").write_bytes(png)

Use a different server and operation timeout when needed:

client = ACOBClient(
    "0123456789ab4def8123456789abcdef",
    endpoint="http://127.0.0.1:8000",
    timeout=90,
)

Action methods map directly to the API actions and payload fields. They submit an instruction, poll until Chromium completes it, and return the action's result.

The tabs() method mirrors the four tab operations:

tabs = client.tabs(operation="list")
tab = client.tabs(
    operation="navigate",
    tid=123,
    url="https://example.com",
)
tab = client.tabs(operation="focus", tid=123)
closed = client.tabs(operation="close", tid=123)

screenshot() returns the API's screenshot metadata unchanged. Its download_url is single-use, so pass it directly to download_screenshot() when ready to consume the PNG.

For lower-level queue control, use submit(), wait(), and execute():

instruction = client.submit("tabs", operation="list")
terminal_response = client.wait(instruction["id"])

result = client.execute("tabs", operation="list")

wait() returns the complete terminal response because that response is single-use. execute() and the action helpers raise ACOBInstructionError when Chromium reports a failed instruction. HTTP validation errors raise ACOBHTTPError; connection, protocol, and timeout failures derive from ACOBError.

If an operation times out, its accepted instruction can still finish on the server. ACOBTimeoutError.instruction_id retains its ID so it can be passed to wait() again.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acob_client-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acob_client-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file acob_client-0.1.0.tar.gz.

File metadata

  • Download URL: acob_client-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for acob_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 81a16b7349542b3cb411d7c000a65945db643534b9da8806e8e6834e6e2d0c81
MD5 124b6dbc8cd6110b3079f46d3137e405
BLAKE2b-256 dbe077cd165aee32b77775ce8153cace023c4aac475b648e17ee3d8f17e59af9

See more details on using hashes here.

File details

Details for the file acob_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: acob_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for acob_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5beaf2792503d3d38f4c67a7c37f298ce687181a1743f1d3d77646150725d6da
MD5 43c656e1f4a46f3342bcaf2f2e1251f8
BLAKE2b-256 ee308a675c810a8e63e019d0ff3e62bd07b929685d97add70fb668c069bfb926

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page