Skip to main content

Python SDK for the Ant Browser daemon

Project description

antbrowser

antbrowser 是 Ant Browser 的 Python SDK,配套 ant-browser-daemon 使用。

当前交付目标:

  • Windows / Linux 可用
  • Android / Termux 提供 Chromium-only 工作流
  • SDK 可自动发现或拉起 daemon
  • Python 既能用高层 API,也能直接调 raw HTTP API
  • Windows / Linux / Android(arm64-v8a) 的 PyPI wheel 可内嵌 daemon

Features

  • 自动复用 workspace/runtime/daemon.json
  • 找不到 daemon 时,优先找本地 binary,再回退到 go run ./cmd/ant-browser-daemon
  • 支持 profiles / instances / page / inspect / tls / stealth
  • 新增 cores / proxies 管理接口
  • 支持 Termux 下直接注册 chromium 可执行文件
  • POSIX/Termux 下会把 wheel 内嵌 daemon materialize 到 workspace/runtime/bin/ 再启动,避免安装后缺少执行位

Quick Example

from antbrowser import AntBrowser

with AntBrowser(workspace="C:/tmp/ant-workspace") as browser:
    print(browser.runtime.info())
    print(browser.discover_system_cores())

High-Level Builder Example

from antbrowser import AntBrowser

with AntBrowser(workspace="C:/tmp/ant-workspace") as browser:
    result = (
        browser.new_profile("buyer-random")
        .random_environment(name_prefix="Buyer Random")
        .hardware(hardware_concurrency=8, device_memory=16)
        .anti_detect("strict")
        .create(auto_launch=True, run_mode="headless")
    )
    print(result)

Core Management

with AntBrowser(workspace="C:/tmp/ant-workspace") as browser:
    core = browser.ensure_core(
        "C:/Program Files/Google/Chrome/Application",
        core_name="Local Chrome",
        is_default=True,
    )
    print(core)

Linux / Termux 也可以直接传可执行文件路径:

browser.ensure_core("/usr/bin/chromium", core_name="Chromium", is_default=True)

Proxy Management

with AntBrowser(workspace="C:/tmp/ant-workspace") as browser:
    proxy = browser.save_proxy(
        {
            "proxyName": "Local Proxy",
            "proxyConfig": "http://127.0.0.1:7890",
            "groupName": "local",
        }
    )
    print(proxy)

Termux

参考:

Docs

Validation

发布前可运行真实验收:

$env:PYTHONPATH="C:\path\to\repo\packages\ant-browser-py\src"
python packages/ant-browser-py/scripts/validate_sdk.py

这会生成:

  • packages/ant-browser-py/docs/VALIDATION_REPORT.md

如果你已经装了 buildtwine,也可以直接跑一键发布前检查:

python packages/ant-browser-py/scripts/release_prep.py

PyPI Artifacts

现在 packages/ant-browser-py/dist/ 中的 Windows / Linux / Android wheel 都是内嵌 daemon 的平台 wheel:

  • antbrowser-1.0.0-py3-none-win_amd64.whl
  • antbrowser-1.0.0-py3-none-linux_x86_64.whl
  • antbrowser-1.0.0-py3-none-linux_aarch64.whl
  • antbrowser-1.0.0-py3-none-android_24_arm64_v8a.whl

这些 wheel 安装后,不需要额外设置 ANT_BROWSER_DAEMON_BIN 也可以直接拉起内嵌 daemon。

Android wheel 当前定位为:

  • 面向 Termux / Android arm64-v8a
  • wheel tag 使用 android_24_arm64_v8a
  • 默认按 Android 7.0+ / API 24 基线发布

如果你的 Python / pip 环境还没有暴露 Android wheel tag,仍然可以先使用:

  • source distribution antbrowser-1.0.0.tar.gz
  • 或仓库里的 Android bundle / install_termux.sh

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

antbrowser-1.0.0.tar.gz (42.1 kB view details)

Uploaded Source

Built Distributions

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

antbrowser-1.0.0-py3-none-win_amd64.whl (24.7 MB view details)

Uploaded Python 3Windows x86-64

antbrowser-1.0.0-py3-none-manylinux_2_17_x86_64.whl (25.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

antbrowser-1.0.0-py3-none-manylinux_2_17_aarch64.whl (23.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

antbrowser-1.0.0-py3-none-android_24_arm64_v8a.whl (23.8 MB view details)

Uploaded Android API level 24+ ARM64 v8aPython 3

File details

Details for the file antbrowser-1.0.0.tar.gz.

File metadata

  • Download URL: antbrowser-1.0.0.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for antbrowser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c3a9b39f2c6f2a50bdcf0375e4598e9225118efc0e4a3ade2e4bad37a08b3027
MD5 7c6030dc7789d52028271a7c1e1123d5
BLAKE2b-256 0964a6a0a46885abfaa5b88f30d680c94226b690307efc2b8f1dd4321fad77d1

See more details on using hashes here.

File details

Details for the file antbrowser-1.0.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: antbrowser-1.0.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 24.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for antbrowser-1.0.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3e62dd65988add2f6e06c091e299f77abfb92d9543a93840789d0fa08cbc5237
MD5 f8a9719ebadc2702cc9bd4c8eb5a7077
BLAKE2b-256 677adffb3d319b0a8c6cb22b908d5e7fbeb3494b95bfa3dc469ff5882e994551

See more details on using hashes here.

File details

Details for the file antbrowser-1.0.0-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for antbrowser-1.0.0-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6d79d0e1b8ca94dd6dbc98f9fb4c9c0872f4f89bf302b609e5681b4c33a33d24
MD5 e43f1aae5d48d8fc771fa07527fb9f93
BLAKE2b-256 10e5a486d5c80afdef973db182b77ce482bf74bd8545e90121f6fe71998c2303

See more details on using hashes here.

File details

Details for the file antbrowser-1.0.0-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for antbrowser-1.0.0-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 4048a3cec592f4037746b925789ac215bea1fbe7378621820d79bb0a828ee8b2
MD5 c184d85f69e29bbfceee51b59bc74831
BLAKE2b-256 e05d2c2353b9f2716d688ffeec39919c28cf4d7888fc9b0a625cb4ccfd155bf4

See more details on using hashes here.

File details

Details for the file antbrowser-1.0.0-py3-none-android_24_arm64_v8a.whl.

File metadata

File hashes

Hashes for antbrowser-1.0.0-py3-none-android_24_arm64_v8a.whl
Algorithm Hash digest
SHA256 620f44ab97aef48eb9859fc8ab739ce6d2e5f7f5cb96b9e35fa464c741c1cdd5
MD5 686b24384ad54e4d22e97e9e29fb3462
BLAKE2b-256 f70e67fec0418fff1c31627b290ea65cd9862bab281140b7d6c925c42e571b1d

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