Skip to main content

YSbrowser SDK 0.11.13

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

安装

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

python -m pip install --upgrade ysbrowser-sdk

Windows / Linux 均可运行以下命令,自动选择配套的 YSbrowser 6.11: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.11 发布说明。

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 所需的共享库、字体和沙箱运行依赖。配套 Linux 包提供本地语音运行组件;实际播放声音需要可用的音频输出。在 WSL 中显示窗口和播放声音,还需要可用的 WSLg 图形和音频环境。

鼠标操作

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

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

便携用户数据

启动参数 --portable-user-data 用于便携用户数据。迁移时完整复制已关闭的用户目录,包括 Local State。

同步和异步 SDK 均可设置:

with YSBrowser(portable_user_data=True) as browser:
    context = browser.new_context()

该选项仅控制浏览器启动模式,不会将 new_context() 改为持久化会话。SDK 的临时用户目录与无痕 Context 不应作为长期登录资料保存方式;Context 登录状态使用 storage_state 导出/恢复。需要长期保留完整用户目录时使用浏览器命令行:

YSbrowser --user-data-dir="./profiles/profile-01" --portable-user-data

Linux 将目录替换为本机路径。已有资料需先在原环境完成迁移;此参数不能恢复原本已无法解密的数据。整个目录包含登录凭据,请妥善保管。

Metadata

Release files for ysbrowser-sdk 0.11.13

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.13
File Size Uploaded Provenance Actions
ysbrowser_sdk-0.11.13.tar.gz 16.6 MB Without provenance Details for ysbrowser_sdk-0.11.13.tar.gz

Built distribution (wheel)

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

Total release size: 32.2 MB

Release files / ysbrowser_sdk-0.11.13.tar.gz

Download URL ysbrowser_sdk-0.11.13.tar.gz
Size 16.6 MB
Tags Source
SHA-256 checksum
How to use checksums
704b250102afc113482a84128a30a704b4b287595cb76e89675dbc8fada9c146
BLAKE2b-256 checksum
How to use checksums
0033084a6f7d25c0562dd7c8ee20ae1aa3c6eca996a70ea9e9687ab04c9254cd
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.13-py3-none-any.whl

Download URL ysbrowser_sdk-0.11.13-py3-none-any.whl
Size 15.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
53dbddf4c6ed71c2020d17fc7810bda593372fccfd90df4167faddb87a37a9d2
BLAKE2b-256 checksum
How to use checksums
2f9e393f7889e8697220bd55a37e2dc6df4ea7e59dfe8d92c39a8684a8b243d2
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.13

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