1.6 KiB
| name | description |
|---|---|
| browser-harness | Use browser-harness for any web automation or scraping task. |
browser-harness
Direct browser control via CDP. For setup, install, or connection problems, read https://github.com/browser-use/browser-harness/blob/main/install.md.
When Not to Use
A basic fetch of public information needs no browser. If a plain HTTP request can read it — a public page, an API, docs — use curl or your fetch tool. Use browser-harness when the task needs interaction (click, type, navigate), the user's logged-in session, JS rendering, or a bot-protected page.
Usage
browser-harness <<'PY'
print(page_info())
PY
- Invoke as
browser-harness. Use heredocs for multi-line commands. - Helpers are pre-imported.
run.pycallsensure_daemon()beforeexec. - First navigation is
new_tab(url), notgoto_url(url).
Local Chrome
browser-harness --doctor
If Chrome is not running, the harness launches it automatically. If remote debugging is not enabled, it opens chrome://inspect/#remote-debugging — ask user to tick the checkbox.
Remote Browsers
browser-harness auth login
browser-harness <<'PY'
start_remote_daemon("r7k2")
PY
Then: BU_NAME=r7k2 browser-harness <<'PY' ... PY
Key Helpers
page_info() new_tab(url) click(sel) type(sel,text) screenshot() extract(sel) evaluate(js) wait(ms) wait_for(sel) navigate(url) close_tab() switch_tab(i) tabs() scroll(dir,amt) press(key) fill_form(fields) upload_file(sel,path)
Use browser-harness <<'PY' ... PY for multi-line scripts.