通过 browser-harness CLI 控制用户本机浏览器(Edge 或 Chrome)。
```bash
git clone https://github.com/browser-use/browser-harness
cd browser-harness
uv tool install -e .
```
```bash
# Edge(推荐):
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --remote-debugging-port=9222
# 或 Chrome:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
```
```bash
$env:BU_CDP_URL="http://127.0.0.1:9222"
```
browser-harness -c "new_tab('https://example.com'); wait_for_load(); capture_screenshot()"
截图保存到 C:\Users\he\AppData\Local\Temp\shot.png,用完后复制到工作目录分析。
browser-harness -c "new_tab('https://example.com')" # 新标签页打开
browser-harness -c "goto_url('https://example.com')" # 在当前标签页打开
browser-harness -c "new_tab('https://example.com'); wait_for_load()"
browser-harness -c "print(page_info())" # URL、标题、尺寸
browser-harness -c "js('document.body.innerText')" # 页面文字内容
browser-harness -c "js('document.title')" # 标题
browser-harness -c "js('document.querySelectorAll(\"a\").length')" # 链接数量
browser-harness -c "close_tab()"
new_tab(),不要用 goto_url()(会覆盖用户当前页面)C:\Users\he\AppData\Local\Temp\shot.png 复制出来分析wait_for_load() 在导航后必须调用web_fetch 抓不到的页面可以用这个BROWSER_USE_API_KEY 和 start_remote_daemon() 可用远程浏览器# 检查调试端口是否开启
Invoke-RestMethod "http://localhost:9222/json/version"
# 有返回说明端口正常
Stop-Process -Name msedge -Force
Start-Process "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --remote-debugging-port=9222
共 1 个版本
暂无安全检测报告