Skip to main content

YSbrowser SDK 0.11.5

配套 YSbrowser 定制浏览器的 Python 自动化库,支持 Windows 和 Linux,提供同步与异步接口、浏览器上下文配置、代理、登录状态保存、模型鼠标轨迹和诊断功能。

安装

需要 Python 3.10 或更高版本。在运行脚本的同一个 Python 环境安装:

python -m pip install --upgrade ysbrowser-sdk

Windows / Linux 均可运行以下命令,自动选择配套的 YSbrowser 6.4:Windows 下载 chrome.7z,Linux 下载 Ubuntu 24.04 x86_64 AppImage。默认资产自动校验 SDK 内置的 SHA-256。

python -m ysbrowser_sdk install

浏览器默认安装到当前目录的 ./browsers,下载压缩包在解压完成后删除。随后在同一工作目录运行自动化脚本。需要其他版本时,可通过 --url 指定压缩包直链。

Linux 默认下载 AppImage,无需配置下载地址。也可设置 YSBROWSER_LINUX_BROWSER_URL 或 --url 覆盖。安装器赋予执行权限并记录入口,不会在安装期间执行下载的文件。SDK 与 AppImage 必须在同一个 Linux/WSL 环境运行;当前默认 Linux 包面向 Ubuntu 24.04 x86_64,要求 AVX2、FMA、F16C。Ubuntu AppArmor 沙箱处理见 6.4 发布说明。

Python 包不包含浏览器,依赖 Patchright 1.64.2、NumPy 和 ONNX Runtime;鼠标模型推理不需要 PyTorch。请勿单独升级固定版本的 Patchright。

同步使用

from ysbrowser_sdk.sync_api import YSBrowser

with YSBrowser(headless=False) as browser:
    context = browser.new_context()
    page = context.new_page()
    page.set_content('<button style="position:absolute;left:700px;top:300px">目标</button>')
    mouse = context.mouse(page)

    # 按模型轨迹从指定起点移动到终点
    result = mouse.move_between(100, 200, 500, 300)

    # 移动到指定元素并点击
    result = mouse.click_element(page.get_by_role("button", name="目标"))
    print(result.plan.model_id, result.plan.data_source)

异步代码从 ysbrowser_sdk.async_api 导入,使用 async with,并在异步操作前加 await。完整示例见使用手册。

Windows 与 Linux 配置

两种系统使用同一个 Python 安装包和同一套同步、异步接口。所有文件路径均相对于运行 Python 的系统解析。

省略 server_gpu_backend 时,Windows 默认使用 warp,Linux 默认使用 llvmpipe。显式指定时会在启动前校验:

系统 支持的图形后端
Windows warp、swiftshader
Linux llvmpipe、native、software、swiftshader

已有浏览器时,可以直接传入可执行文件路径:

from ysbrowser_sdk.sync_api import YSBrowser

# Windows 使用 ./browser/chrome.exe;Linux 使用 ./browser/chrome
with YSBrowser(executable_path="./browser/chrome.exe", headless=False) as browser:
    context = browser.new_context()
    page = context.new_page()
    page.set_content("<h1>浏览器已启动</h1>")

Linux 需要安装 Chromium 所需的共享库、字体和沙箱运行依赖。在 WSL 中显示窗口及播放系统语音,还需要可用的 WSLg 图形和音频环境。

鼠标操作

鼠标轨迹由随包模型生成。move()、move_to() 使用绝对坐标,move_by() 使用相对距离,move_between() 指定起点和终点。省略 duration_s 时,模型自动预测运动时长。

模型操作通过 context.mouse(page) 调用;page.mouse 和定位器仍按 Patchright 原生接口使用。

Metadata

Release files for ysbrowser-sdk 0.11.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ysbrowser-sdk 0.11.5
File Size Uploaded Provenance Actions
ysbrowser_sdk-0.11.5.tar.gz 16.6 MB Without provenance Details for ysbrowser_sdk-0.11.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ysbrowser-sdk 0.11.5
File Interpreter ABI Platform Actions
ysbrowser_sdk-0.11.5-py3-none-any.whl Python 3 none any Details for ysbrowser_sdk-0.11.5-py3-none-any.whl

Total release size: 32.2 MB

Release files / ysbrowser_sdk-0.11.5.tar.gz

Download URL ysbrowser_sdk-0.11.5.tar.gz
Size 16.6 MB
Tags Source
SHA-256 checksum
How to use checksums
239c56a53a613c5269685fd531a2fff30349fa6b0e164b676f236fe9e9a727b3
BLAKE2b-256 checksum
How to use checksums
76dfdbc7cac44c4181f193fbe41be692e33868fff07945b9e95ab9afdc72069c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / ysbrowser_sdk-0.11.5-py3-none-any.whl

Download URL ysbrowser_sdk-0.11.5-py3-none-any.whl
Size 15.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4b10289d44271b0e0b28766d66afcaa94085758b9eca9f6880f7cb3759f98e99
BLAKE2b-256 checksum
How to use checksums
5a245afd0e9672b73502cc127ab89544c7ef2ee642cbbcf6bfa240c31e774417
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for ysbrowser-sdk 0.11.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page