Skip to main content

YSbrowser SDK 0.11.4

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

安装

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

python -m pip install --upgrade ysbrowser-sdk

Windows 在项目工作目录运行以下命令,默认下载配套的 YSBrowser 6.3:

python -m ysbrowser_sdk install

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

Linux 需要配套的 Linux 原生浏览器。将压缩包地址设置为环境变量 YSBROWSER_LINUX_BROWSER_URL 后运行同一安装命令,或用 --url 指定地址;未配置地址时会提示错误,不会下载 Windows 浏览器。

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.4

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.4
File Size Uploaded Provenance Actions
ysbrowser_sdk-0.11.4.tar.gz 16.5 MB Without provenance Details for ysbrowser_sdk-0.11.4.tar.gz

Built distribution (wheel)

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

Total release size: 32.2 MB

Release files / ysbrowser_sdk-0.11.4.tar.gz

Download URL ysbrowser_sdk-0.11.4.tar.gz
Size 16.5 MB
Tags Source
SHA-256 checksum
How to use checksums
ea14b800d6899547efc543f4f28a2fe38a8fd8c1e2fcebe8e65f466ac28d11cb
BLAKE2b-256 checksum
How to use checksums
361f74d12629476a651fa8ab87c72eb89ee00b81703e6d67f10fc92387d855f9
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.4-py3-none-any.whl

Download URL ysbrowser_sdk-0.11.4-py3-none-any.whl
Size 15.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ae592fe631fc0533a420a013b14d8cdb602f5bd14825700ca9372419ae2eab6e
BLAKE2b-256 checksum
How to use checksums
c290b442cf258b47e6dbb07d4d41a6971ea8798d54b30ba5d552d5455500755d
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.4

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