browser4-cli 4.12.2 โ 4.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +525 -663
- package/bin/browser4-cli-darwin-arm64 +0 -0
- package/bin/browser4-cli-darwin-x64 +0 -0
- package/bin/browser4-cli-linux-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-x64 +0 -0
- package/bin/browser4-cli-linux-x64 +0 -0
- package/bin/browser4-cli-win32-x64.exe +0 -0
- package/package.json +5 -1
- package/scripts/README.md +18 -0
- package/scripts/sync-readme.mjs +44 -0
package/README.md
CHANGED
|
@@ -1,43 +1,163 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐ค Browser4
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/platonai/browser4/blob/main/LICENSE)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
English | [็ฎไฝไธญๆ](README.zh.md) | [ไธญๅฝ้ๅ](https://gitee.com/platonai_galaxyeye/Browser4)
|
|
8
|
+
|
|
9
|
+
<!-- TOC -->
|
|
10
|
+
**Table of Contents**
|
|
11
|
+
- [๐ค Browser4](#-browser4)
|
|
12
|
+
- [๐ Introduction](#-introduction)
|
|
13
|
+
- [โจ Key Capabilities](#-key-capabilities)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [๐งญ Tool Selection Guide](#-tool-selection-guide)
|
|
16
|
+
- [How to Interact with a Page](#how-to-interact-with-a-page)
|
|
17
|
+
- [How to Extract Data](#how-to-extract-data)
|
|
18
|
+
- [How to Process at Scale](#how-to-process-at-scale)
|
|
19
|
+
- [How to Turn HTML into Spreadsheets โ Zero Tokens](#how-to-turn-html-into-spreadsheets--zero-tokens)
|
|
20
|
+
- [๐ฆ Installation](#-installation)
|
|
21
|
+
- [๐ก CLI Guide for Humans](#-cli-guide-for-humans)
|
|
22
|
+
- [Quick start](#quick-start-1)
|
|
23
|
+
- [Mental model](#mental-model)
|
|
24
|
+
- [Global options](#global-options)
|
|
25
|
+
- [Key concepts before the command list](#key-concepts-before-the-command-list)
|
|
26
|
+
- [Complete command reference](#complete-command-reference)
|
|
27
|
+
- [Timeout environment variables](#timeout-environment-variables)
|
|
28
|
+
- [State persistence](#state-persistence)
|
|
29
|
+
- [๐ Build from Source](#-build-from-source)
|
|
30
|
+
- [Architecture](#architecture)
|
|
31
|
+
- [๐ฆ Modules Overview](#-modules-overview)
|
|
32
|
+
- [๐งช Test Fixture Server (MockSite)](#-test-fixture-server-mocksite)
|
|
33
|
+
- [๐ค Support & Community](#-support--community)
|
|
34
|
+
- [๐ Documentation](#-documentation)
|
|
35
|
+
- [๐ง Proxy Configuration](#-proxy-configuration---unblock-website-access)
|
|
36
|
+
- [License](#license)
|
|
37
|
+
<!-- /TOC -->
|
|
38
|
+
|
|
39
|
+
## ๐ Introduction
|
|
6
40
|
|
|
7
|
-
|
|
8
|
-
Chrome browser โ clicking, typing, scrolling, and extracting data โ through a
|
|
9
|
-
local server that translates CLI commands into browser actions.
|
|
41
|
+
๐ **Browser4: a fast, intelligent, scalable, multi-scenario agentic browser** ๐
|
|
10
42
|
|
|
11
|
-
|
|
43
|
+
### โจ Key Capabilities
|
|
12
44
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- Run autonomous AI agent tasks from natural-language instructions
|
|
19
|
-
- Save screenshots, PDFs, and full HTML snapshots
|
|
45
|
+
* ๐ค **Agent Browser** โ Browser automation CLI for AI agents.
|
|
46
|
+
* โ๏ธ **Machine Learning Agent** โ Turns complex pages into Excel/structured data without consuming tokens.
|
|
47
|
+
* โก **Extreme Performance** โ Fully coroutine-safe; supports 100k ~ 200k complex page visits per machine per day.
|
|
48
|
+
* ๐งฌ **Data Extraction** โ Hybrid of LLM, ML, X-SQL and selectors for clean data across chaotic pages.
|
|
49
|
+
* ๐ฆ **And More** - Swarm scraping, crawl, batch, loop, stateful sessions, page storage, extension, plugins, and more.
|
|
20
50
|
|
|
21
|
-
|
|
51
|
+
## Quick Start
|
|
22
52
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
53
|
+
Paste the following instruction to your favorite AI agent like claude, codex, workbuddy or openclaw and run it:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Read https://browser4.io/SKILL.md and install browser4-cli (if not installed) for browser automation to perform the following task:
|
|
57
|
+
|
|
58
|
+
1. go to amazon.com
|
|
59
|
+
2. search for pens to draw on whiteboards
|
|
60
|
+
3. compare the first 4 ones
|
|
61
|
+
4. write the result to a markdown file
|
|
62
|
+
```
|
|
30
63
|
|
|
31
|
-
##
|
|
64
|
+
## ๐งญ Tool Selection Guide
|
|
32
65
|
|
|
33
|
-
|
|
66
|
+
Choosing the right tool for your task:
|
|
67
|
+
|
|
68
|
+
### How to Interact with a Page
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Need to interact with a page?
|
|
72
|
+
โโ Need to open or recover a browser session? โ open [url] or goto <url>
|
|
73
|
+
โโ Need to see what is clickable/typeable right now? โ snapshot -i --boxes
|
|
74
|
+
โโ Need to click a button, link, checkbox, or menu item? โ click <ref>
|
|
75
|
+
โโ Need to fill a form field and replace existing text? โ fill <ref> "<text>"
|
|
76
|
+
โโ Need to type naturally into the current field or send Enter/Tab? โ type / press
|
|
77
|
+
โโ Need to choose from a dropdown? โ select <ref> <value>
|
|
78
|
+
โโ Need to hover, drag, scroll, or use the mouse directly? โ hover / drag / scroll / mouse*
|
|
79
|
+
โโ Need to wait for the page to settle before the next step?
|
|
80
|
+
โ โโ Element appears? โ wait <ref|selector>
|
|
81
|
+
โ โโ Text appears? โ wait --text "..."
|
|
82
|
+
โ โโ URL changes? โ wait --url "**/target"
|
|
83
|
+
โ โโ Loading/network finishes? โ wait --load networkidle
|
|
84
|
+
โโ Need to verify what changed after the action? โ snapshot, get, or eval
|
|
85
|
+
โโ Need to repeat many UI steps efficiently? โ batch "goto ..." "click ..." "fill ..."
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Typical interactive flow:
|
|
34
89
|
|
|
35
90
|
```bash
|
|
91
|
+
browser4-cli goto https://example.com/login
|
|
92
|
+
browser4-cli snapshot -i --boxes
|
|
93
|
+
browser4-cli fill e3 "user@example.com"
|
|
94
|
+
browser4-cli fill e4 "secret" --submit
|
|
95
|
+
browser4-cli wait --load networkidle
|
|
96
|
+
browser4-cli snapshot -i
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### How to Extract Data
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Need to extract data from a page?
|
|
103
|
+
โโ Interactive page (click, fill, scroll first)? โ snapshot + refs, then extract
|
|
104
|
+
โโ Static page, one field? โ htmlsnapshot get text "<selector>"
|
|
105
|
+
โโ Static page, all matches of one field? โ htmlsnapshot get all text "<selector>"
|
|
106
|
+
โโ Static page, multiple correlated fields (title+price+url per item)?
|
|
107
|
+
โ โ htmlsnapshot query --sql @query.sql
|
|
108
|
+
โโ Live JS / complex DOM logic? โ eval --json
|
|
109
|
+
โโ Natural language ("find the product price")? โ extract (needs LLM key)
|
|
110
|
+
โโ High volume, many pages? โ crawl or swarm with --sql
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### How to Process at Scale
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
Need to process multiple pages?
|
|
117
|
+
โโ Single list page (search results)? โ htmlsnapshot query with DOM_LOAD_AND_SELECT
|
|
118
|
+
โโ List of known URLs (in a file)? โ crawl --seed-file urls.txt --depth 0 --sql @query.sql
|
|
119
|
+
โโ Crawl from a start URL (follow links)? โ crawl <url> --out-link-selector "..." --depth N
|
|
120
|
+
โโ Need parallel execution (high throughput)? โ swarm create โ swarm query --seed-file ...
|
|
121
|
+
โโ Repeated monitoring (check every hour)? โ loop -- eval "..." -i 3600
|
|
122
|
+
โโ Just a few URLs in a shell script?
|
|
123
|
+
โ for url in ...; do browser4-cli goto "$url"; ... done
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### How to Turn HTML into Spreadsheets โ Zero Tokens
|
|
127
|
+
|
|
128
|
+
[WebMiner](https://github.com/platonai/web-miner) runs ML clustering on downloaded HTML files to produce structured spreadsheets and interactive reports โ **no LLM tokens, everything runs locally.**
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Have HTML files and want structured data โ without tokens?
|
|
132
|
+
โโ < 20 pages? โ browser4-cli crawl --seed-file urls.txt --depth 0 --sql @query.sql
|
|
133
|
+
โโ < 1,000 pages (small to medium)? โ WebMiner Free (SMILE ML engine)
|
|
134
|
+
โ java -jar scent-miner.jar all ./pages/
|
|
135
|
+
โ โ Interactive HTML report + Excel spreadsheets โ local, zero cost
|
|
136
|
+
โโ > 1,000 pages (production scale)? โ WebMiner Commercial (Apache Spark ML)
|
|
137
|
+
โ Same encode โ cluster โ views pipeline, distributed across machines
|
|
138
|
+
โโ Need to acquire pages first?
|
|
139
|
+
โโ Single pages: browser4-cli htmlsnapshot export
|
|
140
|
+
โโ Bulk download: browser4-cli crawl --seed-file urls.txt --depth 0
|
|
141
|
+
โโ High throughput: browser4-cli swarm create โ swarm query --seed-file ...
|
|
142
|
+
Then feed the HTML directory to WebMiner
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> **Pipeline:** `encode` (HTML โ feature vectors โ CSV) โ `cluster` (KMeans, auto-detected K) โ `views` (HTML report + Excel). Free tier uses the [SMILE](https://haifengl.github.io/) ML library for single-machine clustering (< 1,000 pages). Requires JDK 17+. See [web-miner](https://github.com/platonai/web-miner) for install instructions.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## ๐ฆ Installation
|
|
150
|
+
|
|
151
|
+
Manually installation is optional since your AI agent is smart enough to install it after reading the SKILL.
|
|
152
|
+
|
|
153
|
+
Install browser4-cli globally using npm (requires Node.js):
|
|
154
|
+
|
|
155
|
+
```shell
|
|
36
156
|
npm install -g browser4-cli
|
|
37
157
|
browser4-cli install
|
|
38
158
|
```
|
|
39
159
|
|
|
40
|
-
|
|
160
|
+
Or bootstrap the native binary directly with a single command:
|
|
41
161
|
|
|
42
162
|
**Windows (PowerShell):**
|
|
43
163
|
```powershell
|
|
@@ -45,834 +165,576 @@ irm https://browser4.oss-cn-beijing.aliyuncs.com/scripts/install-browser4-cli.ps
|
|
|
45
165
|
browser4-cli install
|
|
46
166
|
```
|
|
47
167
|
|
|
48
|
-
**Linux / macOS:**
|
|
168
|
+
**Linux / macOS (bash):**
|
|
49
169
|
```bash
|
|
50
170
|
curl -fsSL https://browser4.oss-cn-beijing.aliyuncs.com/scripts/install-browser4-cli.sh | bash
|
|
51
171
|
browser4-cli install
|
|
52
172
|
```
|
|
53
173
|
|
|
54
|
-
##
|
|
174
|
+
## ๐ก CLI Guide for Humans
|
|
175
|
+
|
|
176
|
+
`browser4-cli` is a human-usable browser automation shell, not just an agent backend. You can drive a real browser, inspect state, extract structured data, run X-SQL, orchestrate crawl/swarm jobs, manage server plugins and skills, and hand long-running work to built-in AI features.
|
|
177
|
+
|
|
178
|
+
If you want the embedded agent-facing instructions, see [skills/browser4-cli/SKILL.md](skills/browser4-cli/SKILL.md). This section is the human reference.
|
|
179
|
+
|
|
180
|
+
### Quick start
|
|
55
181
|
|
|
56
182
|
```bash
|
|
57
183
|
# Open a browser session
|
|
58
184
|
browser4-cli open --headed https://browser4.io
|
|
59
185
|
|
|
60
|
-
#
|
|
61
|
-
browser4-cli goto https://browser4.io
|
|
62
|
-
|
|
63
|
-
# Inspect the page โ note the eN labels on interactive nodes
|
|
186
|
+
# Inspect the page and get element refs
|
|
64
187
|
browser4-cli snapshot --boxes
|
|
65
188
|
|
|
66
|
-
# Interact using
|
|
189
|
+
# Interact using a ref from the snapshot
|
|
67
190
|
browser4-cli click e15
|
|
68
|
-
browser4-cli
|
|
69
|
-
browser4-cli press e15 Enter
|
|
191
|
+
browser4-cli fill e16 "Browser4" --submit
|
|
70
192
|
|
|
71
|
-
# Extract data
|
|
72
|
-
browser4-cli get text "
|
|
73
|
-
browser4-cli get attr ".product-image" data-src
|
|
193
|
+
# Extract data from the live page
|
|
194
|
+
browser4-cli get text "h1"
|
|
74
195
|
|
|
75
|
-
#
|
|
76
|
-
browser4-cli htmlsnapshot capture
|
|
196
|
+
# Capture a static DOM snapshot for repeated extraction
|
|
77
197
|
browser4-cli htmlsnapshot
|
|
78
198
|
browser4-cli htmlsnapshot get text "#main-content"
|
|
79
199
|
browser4-cli htmlsnapshot query --sql @query.sql
|
|
80
|
-
browser4-cli htmlsnapshot grep -i "error"
|
|
81
200
|
|
|
82
|
-
#
|
|
83
|
-
browser4-cli
|
|
84
|
-
browser4-cli
|
|
201
|
+
# Save output
|
|
202
|
+
browser4-cli screenshot --full-page --filename page.png
|
|
203
|
+
browser4-cli pdf --filename page.pdf
|
|
204
|
+
```
|
|
85
205
|
|
|
86
|
-
|
|
87
|
-
browser4-cli agent run "Search amazon for mechanical keyboards, compare the top 3, write a summary"
|
|
206
|
+
### Mental model
|
|
88
207
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
208
|
+
1. **Session-oriented**: commands work against the current browser session; use `-s <name>` for isolated named sessions.
|
|
209
|
+
2. **Two page views**: `snapshot` is for interactive work with element refs like `e15`; `htmlsnapshot` is for DOM/X-SQL extraction with CSS selectors.
|
|
210
|
+
3. **Interactive vs static extraction**: use `click`, `fill`, `type`, `press`, `wait` when the page must be manipulated first; use `htmlsnapshot query` when you need structured extraction from the DOM.
|
|
211
|
+
4. **Synchronous vs async jobs**: `agent`, `swarm`, `crawl`, and async chat-style commands return task IDs you poll later.
|
|
93
212
|
|
|
94
|
-
|
|
95
|
-
browser4-cli batch "goto https://browser4.io" "snapshot" "screenshot"
|
|
213
|
+
### Global options
|
|
96
214
|
|
|
97
|
-
|
|
98
|
-
browser4-cli screenshot --full-page
|
|
215
|
+
These flags can appear before any command.
|
|
99
216
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
217
|
+
| Flag | Meaning |
|
|
218
|
+
|---|---|
|
|
219
|
+
| `-h`, `--help [command\|category]` | Show top-level help, category help, or detailed command help |
|
|
220
|
+
| `--help-json` | Emit the machine-readable command reference |
|
|
221
|
+
| `-v`, `--version` | Print the CLI version |
|
|
222
|
+
| `-s`, `--session <name>` | Use a named session instead of the default session |
|
|
223
|
+
| `--server <url>` | Override the Browser4 server URL |
|
|
224
|
+
| `--timeout <seconds>` | Override the HTTP timeout for the current command |
|
|
225
|
+
| `--proxy <url>` | Proxy used for runtime downloads/install operations |
|
|
226
|
+
| `--json` | Emit machine-readable JSON only |
|
|
227
|
+
| `--pretty` | Pretty-print JSON output |
|
|
228
|
+
| `-q`, `--quiet` | Suppress normal human-readable output |
|
|
229
|
+
| `-tip`, `--show-tip` | Show a relevant tip on stderr after commands |
|
|
103
230
|
|
|
104
|
-
|
|
105
|
-
browser4-cli close
|
|
106
|
-
```
|
|
231
|
+
### Key concepts before the command list
|
|
107
232
|
|
|
108
|
-
|
|
233
|
+
#### Element refs vs CSS selectors
|
|
109
234
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
| `-v`, `--version` | Print version |
|
|
114
|
-
| `-s <name>` | Named session (isolated state per name) |
|
|
115
|
-
| `--server <url>` | Override Browser4 server URL |
|
|
116
|
-
| `--proxy <url>` | HTTP proxy for runtime downloads only |
|
|
117
|
-
| `--json` | Emit machine-parseable JSON to stdout |
|
|
118
|
-
| `-q`, `--quiet` | Suppress normal output |
|
|
235
|
+
- `snapshot` returns accessibility-tree refs such as `e5`, `e12`, `e42`
|
|
236
|
+
- most interaction commands accept either a snapshot ref or a CSS selector
|
|
237
|
+
- `htmlsnapshot` commands use CSS selectors, not accessibility refs
|
|
119
238
|
|
|
120
|
-
|
|
121
|
-
(`~/.browser4/cli-state.json`). With `-s <name>`, state is stored under
|
|
122
|
-
`~/.browser4/sessions/<name>.json`.
|
|
239
|
+
#### `snapshot` vs `htmlsnapshot`
|
|
123
240
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
produce a JSON envelope with `"status":"error"` and an `"error"` object.
|
|
241
|
+
| Tool | Best for | Input model | Output model |
|
|
242
|
+
|---|---|---|---|
|
|
243
|
+
| `snapshot` | clicking, typing, finding interactive elements | live accessibility tree | refs like `e15` |
|
|
244
|
+
| `htmlsnapshot` | DOM inspection, CSS extraction, X-SQL | stored HTML snapshot | CSS selectors and query results |
|
|
129
245
|
|
|
130
|
-
|
|
246
|
+
#### LLM configuration
|
|
131
247
|
|
|
132
|
-
|
|
248
|
+
AI-powered commands such as `extract`, `summarize`, `chat`, `agent run`, and X-SQL `llm_*` functions require an LLM provider key.
|
|
249
|
+
|
|
250
|
+
| Provider | Environment variables |
|
|
251
|
+
|---|---|
|
|
252
|
+
| DeepSeek | `DEEPSEEK_API_KEY` |
|
|
253
|
+
| OpenRouter | `OPENROUTER_API_KEY`, `OPENROUTER_MODEL_NAME`, `OPENROUTER_BASE_URL` |
|
|
254
|
+
| Volcengine | `VOLCENGINE_API_KEY`, `VOLCENGINE_MODEL_NAME`, `VOLCENGINE_BASE_URL` |
|
|
255
|
+
| OpenAI-compatible | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
|
|
256
|
+
| Aliyun Qwen | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Complete command reference
|
|
263
|
+
|
|
264
|
+
#### Session lifecycle and server administration
|
|
133
265
|
|
|
134
266
|
| Command | Description |
|
|
135
267
|
|---|---|
|
|
136
|
-
| `open [url]` | Open or
|
|
137
|
-
| `attach` | Attach to an existing browser via CDP
|
|
138
|
-
| `close` | Close the active session. |
|
|
139
|
-
| `list` | List sessions with status
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
268
|
+
| `open [url]` | Open a browser session or reconnect to an existing one. Supports `--headed`, `--headless`, `--profile <path>`, `--profile-mode <DEFAULT\|SYSTEM_DEFAULT\|SEQUENTIAL\|TEMPORARY>`, `--interact-level <FASTEST\|FAST\|DEFAULT>`. |
|
|
269
|
+
| `attach` | Attach to an existing browser via CDP or the Browser4 extension. Supports `--cdp <url\|port\|channel>` and remote endpoint options. |
|
|
270
|
+
| `close` | Close the active browser session. |
|
|
271
|
+
| `list` | List browser sessions with their status and next-open behavior. Supports `--all`. |
|
|
272
|
+
| `session-default <name>` | Make a named session become the default unnamed session. |
|
|
273
|
+
| `close-all` | Close all sessions without stopping the backend. |
|
|
274
|
+
| `kill-all` | Force-stop the backend and Browser4-managed browser processes. |
|
|
142
275
|
| `stop` | Gracefully stop the Browser4 server. |
|
|
143
|
-
| `status` |
|
|
144
|
-
| `doctor` | Run
|
|
276
|
+
| `status` | Show server version, port, and health. |
|
|
277
|
+
| `doctor` | Run diagnostics: build info, LLM status, stale daemon cleanup, optional repair. Supports `--verbose` and `--fix`. |
|
|
278
|
+
| `doctor log [name]` | List, view, tail, or grep backend log files. Supports `--tail`, grep-style flags, and `doctor log <name> grep <pattern>`. |
|
|
279
|
+
| `doctor metrics [filter]` | List, filter, or grep backend metrics. Supports `doctor metrics grep <pattern>`. |
|
|
280
|
+
| `delete-data` | Delete session data. |
|
|
281
|
+
| `install` | Install the Browser4 runtime bundle. Supports `--tag <version>` and `--force`. |
|
|
282
|
+
| `upgrade` | Upgrade the CLI/runtime bundle. Supports `--tag <version>` and `--force`. |
|
|
283
|
+
| `uninstall` | Remove global installs and runtime data. Supports `-y`, `--yes`, and `--dry-run`. |
|
|
145
284
|
|
|
146
285
|
```bash
|
|
147
286
|
browser4-cli open --headed https://example.com
|
|
148
|
-
browser4-cli open --profile-mode temporary https://example.com
|
|
149
287
|
browser4-cli attach --cdp chrome
|
|
150
|
-
browser4-cli
|
|
151
|
-
browser4-cli
|
|
288
|
+
browser4-cli doctor --verbose
|
|
289
|
+
browser4-cli doctor log server.log --tail
|
|
290
|
+
browser4-cli doctor metrics grep request
|
|
152
291
|
```
|
|
153
292
|
|
|
154
|
-
|
|
293
|
+
#### Navigation
|
|
155
294
|
|
|
156
295
|
| Command | Description |
|
|
157
296
|
|---|---|
|
|
158
|
-
| `goto <url>` | Navigate to a URL
|
|
159
|
-
| `go-back` | Go back
|
|
160
|
-
| `go-forward` | Go forward
|
|
297
|
+
| `goto <url>` | Navigate to a URL; auto-opens/reconnects a session if needed. |
|
|
298
|
+
| `go-back` | Go back in browser history. |
|
|
299
|
+
| `go-forward` | Go forward in browser history. |
|
|
161
300
|
| `reload` | Reload the current page. |
|
|
162
301
|
|
|
163
|
-
|
|
164
|
-
browser4-cli goto https://example.com
|
|
165
|
-
browser4-cli -s mysession goto https://example.com
|
|
166
|
-
```
|
|
302
|
+
#### Core interaction
|
|
167
303
|
|
|
168
|
-
|
|
304
|
+
All interaction commands accept a snapshot ref such as `e15` or a CSS selector unless noted otherwise. Most of them also support `--no-snapshot` to skip the automatic post-action accessibility snapshot.
|
|
169
305
|
|
|
170
306
|
| Command | Description |
|
|
171
307
|
|---|---|
|
|
172
|
-
| `click <ref> [button]` | Click an element. `--modifiers
|
|
173
|
-
| `dblclick <ref> [button]` | Double-click an element. `--modifiers
|
|
308
|
+
| `click <ref> [button]` | Click an element. Supports `--modifiers`, `--follow`, `--auto-dismiss-dialogs`. |
|
|
309
|
+
| `dblclick <ref> [button]` | Double-click an element. Supports `--modifiers`, `--follow`, `--auto-dismiss-dialogs`. |
|
|
174
310
|
| `hover <ref>` | Hover over an element. |
|
|
175
|
-
| `
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `select <ref> <
|
|
179
|
-
| `check <ref>` | Check a checkbox or radio. |
|
|
180
|
-
| `uncheck <ref>` | Uncheck a checkbox or radio. |
|
|
311
|
+
| `fill <ref> <text>` | Clear and fill text into an editable field. Supports `--submit`, `--verify`. |
|
|
312
|
+
| `type <text> [ref]` | Type text into the focused element or a target element. Supports `--submit`, `--verify`, `--focus`, `--interactable-timeout`. |
|
|
313
|
+
| `press <key> [ref]` | Press a key on the focused element or a target element. Supports `--verify`, `--follow`. |
|
|
314
|
+
| `select <ref> <value>` | Select a dropdown value. Supports `--verify`. |
|
|
315
|
+
| `check <ref>` | Check a checkbox or radio button. |
|
|
316
|
+
| `uncheck <ref>` | Uncheck a checkbox or radio button. |
|
|
317
|
+
| `drag <startRef> <endRef>` | Drag and drop from one element to another. |
|
|
318
|
+
| `wait [target]` | Wait for a selector/ref, duration, text, URL pattern, page-load state, or JavaScript expression. Supports `--timeout`, `--text`, `--url`, `--load`, `--fn`. |
|
|
181
319
|
|
|
182
|
-
|
|
183
|
-
or CSS selectors (e.g. `#submit-btn`, `.menu-item`).
|
|
320
|
+
`wait --load` accepts `domcontentloaded`, `load`, and `networkidle`.
|
|
184
321
|
|
|
185
322
|
```bash
|
|
186
|
-
browser4-cli click
|
|
187
|
-
browser4-cli fill
|
|
188
|
-
browser4-cli type "
|
|
189
|
-
browser4-cli
|
|
323
|
+
browser4-cli click e8 --follow
|
|
324
|
+
browser4-cli fill e4 "john@example.com" --submit
|
|
325
|
+
browser4-cli type "Browser4" e7 --verify
|
|
326
|
+
browser4-cli wait --text "Success"
|
|
327
|
+
browser4-cli wait --load networkidle
|
|
190
328
|
```
|
|
191
329
|
|
|
192
|
-
|
|
330
|
+
#### Keyboard and mouse
|
|
193
331
|
|
|
194
332
|
| Command | Description |
|
|
195
333
|
|---|---|
|
|
196
|
-
| `press <key> [ref]` | Press a key (`a`, `Enter`, `ArrowLeft`, `Escape`). Supports `--verify`, `--follow` (detect new tabs). |
|
|
197
334
|
| `keydown <key>` | Press and hold a key. |
|
|
198
|
-
| `keyup <key>` | Release a key. |
|
|
199
|
-
| `mousemove <x> <y>` | Move mouse to coordinates. |
|
|
200
|
-
| `mousedown [button]` | Press mouse button
|
|
201
|
-
| `mouseup [button]` | Release mouse button. |
|
|
202
|
-
| `mousewheel <dx> <dy>` | Scroll
|
|
203
|
-
| `scroll <direction> <pixels>` | Scroll the page
|
|
335
|
+
| `keyup <key>` | Release a held key. |
|
|
336
|
+
| `mousemove <x> <y>` | Move the mouse to screen/page coordinates. |
|
|
337
|
+
| `mousedown [button]` | Press a mouse button. |
|
|
338
|
+
| `mouseup [button]` | Release a mouse button. |
|
|
339
|
+
| `mousewheel <dx> <dy>` | Scroll using a wheel delta. |
|
|
340
|
+
| `scroll <direction> <pixels>` | Scroll the page `up`, `down`, `left`, or `right`. |
|
|
204
341
|
|
|
205
|
-
|
|
206
|
-
browser4-cli press Enter e7
|
|
207
|
-
browser4-cli mousemove 200 400
|
|
208
|
-
browser4-cli scroll down 300
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Waiting & dialogs
|
|
342
|
+
#### Page inspection and live extraction
|
|
212
343
|
|
|
213
344
|
| Command | Description |
|
|
214
345
|
|---|---|
|
|
215
|
-
| `
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
346
|
+
| `snapshot` | Capture an accessibility-tree snapshot. Supports `--boxes`, `-i/--interactive`, `-u/--urls`, `-c/--compact`, `--no-compact`, `-d/--depth`, `-l/--limit`, `-s/--selector`, `--raw`, `--stdout`, `-vp/--viewport`, `--filename`. |
|
|
347
|
+
| `snapshot grep <pattern>` | Search saved/current snapshot YAML with grep-style flags such as `-i`, `-v`, `-c`, `-l`, `-F`, `-w`, `-A`, `-B`, `-C`, `--selector`, `--page`, `--page-size`, `--all`. |
|
|
348
|
+
| `snapshot list` | List saved snapshot files with timestamps and sizes. |
|
|
349
|
+
| `snapshot clean` | Remove old snapshot files. Supports `--dry-run`. |
|
|
350
|
+
| `get <mode> <selector> [name]` | Extract `text`, `html`, `box`, `styles`, `property`, or `attr` from a live page element. |
|
|
351
|
+
| `eval [expression] [ref]` | Evaluate JavaScript on the page or an element. Supports `--file`, `--stdin`, `--base64`, `--await`, `--wait-selector`, `--json`. |
|
|
352
|
+
| `console [min-level]` | List browser console messages. Supports `--clear`. |
|
|
353
|
+
| `cdp <method>` | Send an arbitrary Chrome DevTools Protocol command. Supports `--json <params>`. |
|
|
354
|
+
| `generate-locator <ref>` | Generate the best CSS selector for a snapshot ref or existing selector. |
|
|
355
|
+
| `resize <width> <height>` | Resize the browser window. |
|
|
356
|
+
| `dialog-accept [prompt]` | Accept an alert/confirm/prompt dialog, optionally filling the prompt. |
|
|
357
|
+
| `dialog-dismiss` | Dismiss an alert/confirm/prompt dialog. |
|
|
218
358
|
|
|
219
|
-
`
|
|
359
|
+
`get` modes:
|
|
220
360
|
|
|
221
|
-
| Mode |
|
|
361
|
+
| Mode | Meaning | Example |
|
|
222
362
|
|---|---|---|
|
|
223
|
-
|
|
|
224
|
-
|
|
|
225
|
-
|
|
|
226
|
-
|
|
|
227
|
-
|
|
|
228
|
-
|
|
|
229
|
-
|
|
230
|
-
All modes accept `--timeout <ms>` (default: 30000). Load states: `networkidle`,
|
|
231
|
-
`domcontentloaded`, `load`.
|
|
232
|
-
|
|
233
|
-
### Screenshots & PDF
|
|
234
|
-
|
|
235
|
-
| Command | Description |
|
|
236
|
-
|---|---|
|
|
237
|
-
| `screenshot [ref]` | Take a screenshot. `--filename <path>`, `--full-page`, `--viewport <n>`. Optionally of a specific element. |
|
|
238
|
-
| `pdf` | Save page as PDF. `--filename <path>`. |
|
|
363
|
+
| `text` | visible inner text | `browser4-cli get text ".price"` |
|
|
364
|
+
| `html` | inner HTML | `browser4-cli get html "#main"` |
|
|
365
|
+
| `box` | bounding box | `browser4-cli get box "#hero"` |
|
|
366
|
+
| `styles` | computed styles | `browser4-cli get styles e9` |
|
|
367
|
+
| `property` | DOM property value | `browser4-cli get property "input" value` |
|
|
368
|
+
| `attr` | HTML attribute value | `browser4-cli get attr "a" href` |
|
|
239
369
|
|
|
240
370
|
```bash
|
|
241
|
-
browser4-cli
|
|
242
|
-
browser4-cli
|
|
243
|
-
browser4-cli
|
|
371
|
+
browser4-cli snapshot -i --boxes
|
|
372
|
+
browser4-cli snapshot grep -C 2 "button"
|
|
373
|
+
browser4-cli eval "document.title"
|
|
374
|
+
browser4-cli eval --file script.js --await
|
|
375
|
+
browser4-cli console warn
|
|
376
|
+
browser4-cli cdp Runtime.evaluate --json '{"expression":"document.title"}'
|
|
244
377
|
```
|
|
245
378
|
|
|
246
|
-
|
|
379
|
+
#### HTML snapshot and X-SQL extraction
|
|
380
|
+
|
|
381
|
+
`htmlsnapshot` captures a stored raw DOM snapshot and is the center of Browser4's structured extraction workflow.
|
|
247
382
|
|
|
248
383
|
| Command | Description |
|
|
249
384
|
|---|---|
|
|
250
|
-
| `
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
385
|
+
| `htmlsnapshot` | Short form of `htmlsnapshot capture`. |
|
|
386
|
+
| `htmlsnapshot capture` | Capture and store a static HTML snapshot with metadata about the page and interactive elements. |
|
|
387
|
+
| `htmlsnapshot get <field> [selector] [name]` | Extract the first matching `text`, `html`, or `attr` from the stored snapshot. |
|
|
388
|
+
| `htmlsnapshot get all <field> [selector] [name]` | Extract all matching values from the stored snapshot. Supports `--offset` and `--limit`. |
|
|
389
|
+
| `htmlsnapshot query [url]` | Run X-SQL. Supports `--sql <query\|@file>`, `--sql-stdin`, `--sql-base64`, result pagination, and extraction-focused output flags. |
|
|
390
|
+
| `htmlsnapshot export` | Export stored HTML to a file. Supports positional file path or `--file <path>` plus `--clean`. |
|
|
391
|
+
| `htmlsnapshot summary` | Generate a compressed Web Page Summary Index (WPSI). |
|
|
392
|
+
| `htmlsnapshot grep <pattern>` | Search stored HTML with grep-style flags. |
|
|
393
|
+
| `htmlsnapshot inspect [selector]` | Discover recurring DOM patterns and selector candidates. Supports `--max`, `--depth`, `--stdin`, `--selector-base64`. |
|
|
394
|
+
|
|
395
|
+
Important rules:
|
|
396
|
+
|
|
397
|
+
- use `snapshot` when you need refs and interaction
|
|
398
|
+
- use `htmlsnapshot` when you need repeated DOM extraction
|
|
399
|
+
- `htmlsnapshot query --sql @query.sql` is the recommended way to avoid shell quoting issues
|
|
400
|
+
- for correlated list extraction, prefer `htmlsnapshot query` over repeated `get all`
|
|
254
401
|
|
|
255
402
|
```bash
|
|
256
|
-
browser4-cli
|
|
257
|
-
browser4-cli
|
|
258
|
-
browser4-cli
|
|
259
|
-
browser4-cli
|
|
260
|
-
browser4-cli
|
|
261
|
-
browser4-cli
|
|
262
|
-
browser4-cli tab-close --guid 1B46D74FB # close by stable GUID
|
|
403
|
+
browser4-cli htmlsnapshot
|
|
404
|
+
browser4-cli htmlsnapshot get text "#productTitle"
|
|
405
|
+
browser4-cli htmlsnapshot get all text ".result-title" --offset 10 --limit 5
|
|
406
|
+
browser4-cli htmlsnapshot inspect ".s-result-item" --depth 6 --max 20
|
|
407
|
+
browser4-cli htmlsnapshot export --file page.html --clean
|
|
408
|
+
browser4-cli htmlsnapshot query --sql @query.sql
|
|
263
409
|
```
|
|
264
410
|
|
|
265
|
-
|
|
411
|
+
For deep X-SQL usage, see [skills/browser4-cli/references/htmlsnapshot.md](skills/browser4-cli/references/htmlsnapshot.md) and [skills/browser4-cli/references/x-sql-dom-load-select.md](skills/browser4-cli/references/x-sql-dom-load-select.md).
|
|
412
|
+
|
|
413
|
+
#### Screenshots and PDF
|
|
266
414
|
|
|
267
415
|
| Command | Description |
|
|
268
416
|
|---|---|
|
|
269
|
-
| `
|
|
270
|
-
| `
|
|
271
|
-
| `eval <expression> [ref]` | Evaluate JavaScript on the page or a target element. `--file <path>`, `--base64`, or `--stdin` to provide the expression. `--json` to wrap scalar results. |
|
|
272
|
-
| `generate-locator <ref>` | Generate a stable CSS selector path for an element. |
|
|
273
|
-
| `htmlsnapshot` | Short form of `htmlsnapshot capture`. Capture a static HTML snapshot. See [HTML Snapshot](#dom-snapshot) below. |
|
|
274
|
-
| `htmlsnapshot capture` | Capture a static HTML snapshot. See [HTML Snapshot](#dom-snapshot) below. |
|
|
275
|
-
| `extract <instruction>` | Extract structured data with AI. `--schema <json>` for typed output. `--filename <path>`, `--raw`. |
|
|
276
|
-
| `summarize [instruction]` | Summarize page content with AI. `--selector <css>`, `--filename <path>`, `--raw`. |
|
|
417
|
+
| `screenshot [ref]` | Take a page or element screenshot. Supports `--filename`, `--full-page`, `--viewport`. |
|
|
418
|
+
| `pdf` | Save the current page as PDF. Supports `--filename`. |
|
|
277
419
|
|
|
278
|
-
|
|
420
|
+
#### Tabs
|
|
279
421
|
|
|
280
|
-
|
|
|
281
|
-
|
|
282
|
-
| `
|
|
283
|
-
| `
|
|
284
|
-
| `
|
|
285
|
-
| `
|
|
286
|
-
| `property` | DOM property value | `browser4-cli get property "input" value` |
|
|
287
|
-
| `attr` | HTML attribute value | `browser4-cli get attr "a.link" href` |
|
|
288
|
-
|
|
289
|
-
```bash
|
|
290
|
-
browser4-cli eval "document.title"
|
|
291
|
-
browser4-cli eval "el => el.textContent" e15
|
|
292
|
-
browser4-cli eval --file script.js
|
|
293
|
-
browser4-cli eval --base64 ZG9jdW1lbnQudGl0bGU=
|
|
294
|
-
browser4-cli generate-locator e5
|
|
295
|
-
browser4-cli extract "product name, price, and rating"
|
|
296
|
-
browser4-cli extract "contacts" --schema '{"type":"object","properties":{"name":{"type":"string"},"email":{"type":"string"}}}'
|
|
297
|
-
browser4-cli summarize --selector "#reviews"
|
|
298
|
-
```
|
|
422
|
+
| Command | Description |
|
|
423
|
+
|---|---|
|
|
424
|
+
| `tab-list` | List open tabs with indexes, titles, and URLs; use `--json` for full GUIDs. |
|
|
425
|
+
| `tab-new [url]` | Open a new tab, optionally navigating to a URL. |
|
|
426
|
+
| `tab-close [index]` | Close a tab by index; supports `--guid <guid>`. |
|
|
427
|
+
| `tab-select <index>` | Switch to a tab by index; supports `--guid <guid>`. |
|
|
299
428
|
|
|
300
|
-
|
|
429
|
+
#### Browser storage and local page data
|
|
301
430
|
|
|
302
431
|
| Command | Description |
|
|
303
432
|
|---|---|
|
|
304
|
-
| `state-save [
|
|
305
|
-
| `state-load <
|
|
306
|
-
| `cookie-list` | List cookies. `--domain`, `--path
|
|
433
|
+
| `state-save [filename]` | Save cookies and localStorage to a JSON file. |
|
|
434
|
+
| `state-load <filename>` | Restore cookies and localStorage from a JSON file. |
|
|
435
|
+
| `cookie-list` | List cookies. Supports `--domain`, `--path`. |
|
|
307
436
|
| `cookie-get <name>` | Get a cookie by name. |
|
|
308
|
-
| `cookie-set <name> <value>` | Set a cookie. `--domain`, `--path`, `--expires`, `--httpOnly`, `--secure`, `--sameSite
|
|
309
|
-
| `cookie-delete <name>` | Delete a cookie. `--domain`, `--path
|
|
437
|
+
| `cookie-set <name> <value>` | Set a cookie. Supports `--domain`, `--path`, `--expires`, `--httpOnly`, `--secure`, `--sameSite`. |
|
|
438
|
+
| `cookie-delete <name>` | Delete a cookie by name. Supports `--domain`, `--path`. |
|
|
310
439
|
| `cookie-clear` | Clear all cookies. |
|
|
311
440
|
| `localstorage-list` | List localStorage entries. |
|
|
312
|
-
| `localstorage-get <key>` |
|
|
313
|
-
| `localstorage-set <key> <value>` | Set a localStorage
|
|
441
|
+
| `localstorage-get <key>` | Read a localStorage key. |
|
|
442
|
+
| `localstorage-set <key> <value>` | Set a localStorage key. |
|
|
314
443
|
| `localstorage-delete <key>` | Delete a localStorage key. |
|
|
315
|
-
| `localstorage-clear` | Clear
|
|
444
|
+
| `localstorage-clear` | Clear localStorage. |
|
|
316
445
|
| `sessionstorage-list` | List sessionStorage entries. |
|
|
317
|
-
| `sessionstorage-get <key>` |
|
|
318
|
-
| `sessionstorage-set <key> <value>` | Set a sessionStorage
|
|
446
|
+
| `sessionstorage-get <key>` | Read a sessionStorage key. |
|
|
447
|
+
| `sessionstorage-set <key> <value>` | Set a sessionStorage key. |
|
|
319
448
|
| `sessionstorage-delete <key>` | Delete a sessionStorage key. |
|
|
320
|
-
| `sessionstorage-clear` | Clear
|
|
449
|
+
| `sessionstorage-clear` | Clear sessionStorage. |
|
|
450
|
+
| `webdb export <dir>` | Export pages from the Browser4 web database to a local directory. |
|
|
451
|
+
| `webdb normalize <url>` | Normalize a URL into the web database key format. |
|
|
321
452
|
|
|
322
|
-
|
|
323
|
-
browser4-cli state-save auth.json
|
|
324
|
-
browser4-cli state-load auth.json
|
|
325
|
-
browser4-cli cookie-set token abc123 --httpOnly --secure --sameSite Lax
|
|
326
|
-
browser4-cli cookie-list --domain example.com
|
|
327
|
-
```
|
|
453
|
+
#### AI extraction, chat, and autonomous agent tasks
|
|
328
454
|
|
|
329
|
-
|
|
455
|
+
These commands require an LLM key.
|
|
330
456
|
|
|
331
457
|
| Command | Description |
|
|
332
458
|
|---|---|
|
|
333
|
-
| `
|
|
334
|
-
| `
|
|
335
|
-
|
|
336
|
-
`
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
browser4-cli
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
echo '[
|
|
349
|
-
["goto", "https://example.com"],
|
|
350
|
-
["fill", "#name", "Bob"],
|
|
351
|
-
["click", "#submit"]
|
|
352
|
-
]' | browser4-cli batch --json
|
|
353
|
-
|
|
354
|
-
# Loop: run every 5 minutes, 10 iterations
|
|
355
|
-
browser4-cli loop "load https://example.com and extract the page title" -i 300 -n 10
|
|
356
|
-
|
|
357
|
-
# Loop a shell command
|
|
358
|
-
browser4-cli loop --shell "curl -s https://api.example.com/health" -i 60 -n 10
|
|
459
|
+
| `extract <instruction>` | Extract structured data from the current page. Supports `--schema <json\|@file>`, `--filename`, `--raw`, `--stdout`. |
|
|
460
|
+
| `summarize [instruction]` | Summarize the current page. Supports `--selector`, `--filename`, `--raw`, `--stdout`. |
|
|
461
|
+
| `chat <message>` | Send a plain AI chat request without auto-appended browser context. |
|
|
462
|
+
| `chat-result <id>` | Retrieve the result of an async chat task. |
|
|
463
|
+
| `agent run <task>` | Submit an autonomous browser task and immediately receive a task ID. |
|
|
464
|
+
| `agent status <id>` | Check a running task. |
|
|
465
|
+
| `agent result <id>` | Fetch a completed result. |
|
|
466
|
+
| `agent list` | List tracked agent tasks and their status. |
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
browser4-cli extract "product name, price, rating"
|
|
470
|
+
browser4-cli extract "contacts" --schema @schema.json
|
|
471
|
+
browser4-cli summarize --selector "#reviews"
|
|
472
|
+
browser4-cli agent run "Go to amazon.com, compare the first 3 keyboards, write a summary"
|
|
473
|
+
browser4-cli agent status agent-task-1
|
|
359
474
|
```
|
|
360
475
|
|
|
361
|
-
|
|
476
|
+
#### Batch and loop automation
|
|
362
477
|
|
|
363
478
|
| Command | Description |
|
|
364
479
|
|---|---|
|
|
365
|
-
| `
|
|
366
|
-
| `
|
|
367
|
-
|
|
480
|
+
| `batch [command...]` | Execute multiple commands in one invocation. Supports `--bail` and `--json` for stdin-driven command arrays. |
|
|
481
|
+
| `loop [task]` | Run a task repeatedly. Supports `--name`, `-i/--interval`, `-n/--count`, `-t/--timeout`, `--shell`, `--list`, `--pause`, `--resume`, `--pause-all`, `--resume-all`, `--stop`, `--stop-all`, `--status`, `--history`, `--keep-state`. |
|
|
482
|
+
|
|
483
|
+
Batch-compatible commands:
|
|
484
|
+
|
|
485
|
+
```text
|
|
486
|
+
goto go-back go-forward reload press type keydown keyup
|
|
487
|
+
click dblclick hover fill select check uncheck drag
|
|
488
|
+
mousemove mousedown mouseup mousewheel scroll wait
|
|
489
|
+
get eval snapshot screenshot pdf dialog-accept dialog-dismiss
|
|
490
|
+
resize tab-list tab-new tab-close tab-select
|
|
491
|
+
```
|
|
368
492
|
|
|
369
493
|
```bash
|
|
370
|
-
browser4-cli
|
|
371
|
-
browser4-cli
|
|
372
|
-
browser4-cli
|
|
373
|
-
browser4-cli
|
|
374
|
-
browser4-cli uninstall -y
|
|
494
|
+
browser4-cli batch --bail "goto https://example.com" "snapshot" "screenshot"
|
|
495
|
+
browser4-cli loop "load https://example.com and extract the title" -i 300 -n 10
|
|
496
|
+
browser4-cli loop --shell "curl -s https://api.example.com/health" -i 60
|
|
497
|
+
browser4-cli loop --list
|
|
375
498
|
```
|
|
376
499
|
|
|
377
|
-
|
|
500
|
+
#### Swarm and crawl for scale
|
|
378
501
|
|
|
379
|
-
|
|
380
|
-
instructions that always match the installed CLI version.
|
|
502
|
+
The `co` prefix is accepted as an alias for `swarm`.
|
|
381
503
|
|
|
382
504
|
| Command | Description |
|
|
383
505
|
|---|---|
|
|
384
|
-
| `
|
|
385
|
-
| `
|
|
386
|
-
| `
|
|
387
|
-
| `
|
|
388
|
-
| `
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
506
|
+
| `swarm create` | Create a parallel scraping session. Supports `--profile-mode`, `--max-open-tabs`, `--max-browser-contexts`, `--display-mode`. |
|
|
507
|
+
| `swarm submit [url]` | Submit URLs or X-SQL payloads as jobs. Supports `--seed-file`, `--sql`, `--deadline`, `--expires`, `--refresh`, `--parse`. |
|
|
508
|
+
| `swarm query <url>` | Run an X-SQL extraction job against one or more loaded pages. Supports `--sql`, `--seed-file`, `--deadline`, `--expires`, `--refresh`. |
|
|
509
|
+
| `swarm status <id>` | Check a swarm task status. |
|
|
510
|
+
| `swarm result <id>` | Fetch a completed swarm result. |
|
|
511
|
+
| `swarm list` | List tracked swarm tasks. |
|
|
512
|
+
| `swarm close` | Close the swarm session and release browser resources. |
|
|
513
|
+
| `crawl [url]` | Crawl from a URL or seed file. Supports `--seed-file`, `--sql`, `--sql-stdin`, `--sql-base64`, `--format`, `--output`, `-d/--depth`, `-ol/--out-link-selector`, `-olp/--out-link-pattern`, `-tl/--top-links`, `-a/--args`, `--refresh`, `--parse`, `--expires`, `-p/--priority`, `--page-load-timeout`, `--ignore-url-query`, `--no-norm`, `--readonly`, `-bg/--background`. |
|
|
514
|
+
| `crawl status <id>` | Check crawl task status. |
|
|
515
|
+
| `crawl result <id>` | Fetch crawl results. |
|
|
516
|
+
| `crawl cancel <id>` | Cancel a running crawl. |
|
|
517
|
+
| `crawl clear` | Remove terminal-state crawl tasks; supports force-style cleanup options. |
|
|
518
|
+
| `crawl list` | List tracked crawl tasks. |
|
|
393
519
|
|
|
394
520
|
```bash
|
|
395
|
-
browser4-cli
|
|
396
|
-
browser4-cli
|
|
397
|
-
browser4-cli
|
|
398
|
-
browser4-cli
|
|
399
|
-
browser4-cli skills path # Print skills root directory
|
|
400
|
-
browser4-cli skills path browser4-cli # Print path to a specific skill
|
|
401
|
-
browser4-cli skills unpack # Unpack to default skills directory
|
|
402
|
-
browser4-cli skills unpack /custom/path # Unpack to a custom directory
|
|
521
|
+
browser4-cli swarm create --max-open-tabs 12 --display-mode HEADLESS
|
|
522
|
+
browser4-cli swarm query --seed-file urls.txt --sql @query.sql --refresh
|
|
523
|
+
browser4-cli crawl "https://example.com" --depth 2 --out-link-selector "a[href]"
|
|
524
|
+
browser4-cli crawl list
|
|
403
525
|
```
|
|
404
526
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
| Command | Description |
|
|
408
|
-
|---|---|
|
|
409
|
-
| `resize <w> <h>` | Resize the browser window. |
|
|
410
|
-
| `delete-data` | Delete session data (cookies, storage, cache). |
|
|
411
|
-
| `console [min-level]` | List console messages. `--clear` to clear. |
|
|
412
|
-
| `upload <ref> <file>` | Upload files to a file input. |
|
|
413
|
-
|
|
414
|
-
---
|
|
415
|
-
|
|
416
|
-
## Commands with subcommands
|
|
417
|
-
|
|
418
|
-
### Snapshot
|
|
527
|
+
#### Bundled skill files vs installed runtime skills
|
|
419
528
|
|
|
420
|
-
|
|
421
|
-
element is labeled with a ref (`e15`, `e42`) that you can pass directly to
|
|
422
|
-
`click`, `type`, `fill`, and other interaction commands.
|
|
423
|
-
|
|
424
|
-
```
|
|
425
|
-
browser4-cli snapshot [options]
|
|
426
|
-
browser4-cli snapshot grep [OPTIONS] <pattern>
|
|
427
|
-
```
|
|
529
|
+
Browser4 has two different "skill" surfaces:
|
|
428
530
|
|
|
429
|
-
|
|
531
|
+
1. **`skills ...`** manages bundled, embedded skill documents that ship with the CLI.
|
|
532
|
+
2. **`skill-*`** manages installed runtime skills exposed by the backend.
|
|
430
533
|
|
|
431
|
-
|
|
534
|
+
##### Bundled CLI skills
|
|
432
535
|
|
|
433
|
-
|
|
|
536
|
+
| Command | Description |
|
|
434
537
|
|---|---|
|
|
435
|
-
|
|
|
436
|
-
|
|
|
437
|
-
|
|
|
438
|
-
|
|
|
439
|
-
|
|
|
440
|
-
| `--no-compact` | Include all structural nodes |
|
|
441
|
-
| `-d`, `--depth <n>` | Limit tree depth |
|
|
442
|
-
| `-l`, `--limit <n>` | Cap total rendered nodes |
|
|
443
|
-
| `-s`, `--selector <css>` | Scope snapshot to a CSS selector |
|
|
444
|
-
| `--raw`, `--stdout` | Print directly to stdout (for piping) |
|
|
445
|
-
| `-vp`, `--viewport <spec>` | Capture specific viewports (e.g. `0,2,4` or `1-3`) |
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
# Full snapshot with bounding boxes
|
|
449
|
-
browser4-cli snapshot --boxes
|
|
450
|
-
|
|
451
|
-
# Interactive elements only, depth-limited
|
|
452
|
-
browser4-cli snapshot -i -c -d 5
|
|
453
|
-
|
|
454
|
-
# Scope to a specific section, pipe to grep
|
|
455
|
-
browser4-cli snapshot -s "#main-content" --raw | grep "button"
|
|
456
|
-
|
|
457
|
-
# Capture specific viewports
|
|
458
|
-
browser4-cli snapshot --viewport 0,2,4
|
|
459
|
-
```
|
|
538
|
+
| `skills` | List bundled skill names. |
|
|
539
|
+
| `skills list` | Same as `skills`. |
|
|
540
|
+
| `skills get <name>` | Print a skill's `SKILL.md`. Supports `--full` and `--all`. |
|
|
541
|
+
| `skills path [name]` | Print the bundled skill directory path. |
|
|
542
|
+
| `skills unpack [dest]` | Unpack bundled skill files to a directory. |
|
|
460
543
|
|
|
461
|
-
|
|
544
|
+
##### Installed runtime skills
|
|
462
545
|
|
|
463
|
-
|
|
464
|
-
Line numbers are shown by default.
|
|
465
|
-
|
|
466
|
-
| Flag | Description |
|
|
546
|
+
| Command | Description |
|
|
467
547
|
|---|---|
|
|
468
|
-
|
|
|
469
|
-
|
|
|
470
|
-
|
|
|
471
|
-
|
|
|
472
|
-
|
|
|
473
|
-
| `-F` | Treat pattern as a literal string |
|
|
474
|
-
| `-w` | Match whole words only |
|
|
475
|
-
| `--no-line-number` | Suppress line numbers |
|
|
476
|
-
| `--selector <css>` | Scope search to a CSS selector |
|
|
477
|
-
| `--page N`, `--page-size N`, `--all` | Output pagination (2000 lines per page default) |
|
|
478
|
-
|
|
479
|
-
```bash
|
|
480
|
-
browser4-cli snapshot grep -i error
|
|
481
|
-
browser4-cli snapshot grep -C 2 "timeout"
|
|
482
|
-
browser4-cli snapshot grep -F -w "Error" --selector main
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
---
|
|
548
|
+
| `skill-list` | List installed backend skills. |
|
|
549
|
+
| `skill-info <id>` | Show detailed skill metadata. |
|
|
550
|
+
| `skill-install <path>` | Install a skill from a directory containing `SKILL.md`. Supports `--overwrite`. |
|
|
551
|
+
| `skill-uninstall <id>` | Remove a skill by ID. |
|
|
552
|
+
| `skill-reload <id>` | Reload a skill from its source directory. |
|
|
486
553
|
|
|
487
|
-
|
|
554
|
+
#### Progressive experience memory
|
|
488
555
|
|
|
489
|
-
|
|
490
|
-
HTML capture stored in the backend that can be queried repeatedly without
|
|
491
|
-
re-fetching. Unlike the accessibility `snapshot`, this works against the raw DOM.
|
|
556
|
+
These commands operate on Browser4's learned experience store.
|
|
492
557
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
browser4-cli htmlsnapshot export [--file <path>] [--clean]
|
|
500
|
-
browser4-cli htmlsnapshot summary
|
|
501
|
-
browser4-cli htmlsnapshot grep [OPTIONS] <pattern>
|
|
502
|
-
browser4-cli htmlsnapshot inspect [selector] [--max N] [--depth D]
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
#### htmlsnapshot / htmlsnapshot capture
|
|
506
|
-
|
|
507
|
-
Capture the DOM and display metadata (URL, title, timestamps, image/link counts,
|
|
508
|
-
interactive elements with tag, class, id, aria, and bounding boxes).
|
|
509
|
-
`htmlsnapshot` is a short form of `htmlsnapshot capture`.
|
|
510
|
-
|
|
511
|
-
```bash
|
|
512
|
-
browser4-cli htmlsnapshot capture
|
|
513
|
-
browser4-cli htmlsnapshot
|
|
514
|
-
```
|
|
558
|
+
| Command | Description |
|
|
559
|
+
|---|---|
|
|
560
|
+
| `experience save <url> <trace>` | Save a task execution trace. Supports `--outcome`, `--intent`, `--task-type`. |
|
|
561
|
+
| `experience query <url>` | Query known selectors, blockers, and hints for a URL/domain. Supports `--intent`. |
|
|
562
|
+
| `experience list` | List stored experience entries. Supports `--filter`, `--intent-filter`, `--page`, `--page-size`. |
|
|
563
|
+
| `experience deep-learn <url> <intent>` | Run deeper analysis on stored traces. Supports `--force`. |
|
|
515
564
|
|
|
516
|
-
####
|
|
565
|
+
#### Plugins
|
|
517
566
|
|
|
518
|
-
|
|
567
|
+
Plugins are server-side JARs that extend Browser4.
|
|
519
568
|
|
|
520
|
-
|
|
|
521
|
-
|
|
522
|
-
| `
|
|
523
|
-
| `
|
|
524
|
-
| `
|
|
569
|
+
| Command | Description |
|
|
570
|
+
|---|---|
|
|
571
|
+
| `plugin list` | List installed plugins. |
|
|
572
|
+
| `plugin info <name>` | Show plugin details. |
|
|
573
|
+
| `plugin install <file>` | Install a plugin from a local JAR file. Supports `--replace`. |
|
|
574
|
+
| `plugin remove <name>` | Remove a plugin. Supports `-y`, `--yes`. |
|
|
525
575
|
|
|
526
|
-
|
|
527
|
-
`get text` is not paginated by default. Use `--page N`, `--page-size N`, or `--all`.
|
|
576
|
+
#### Advanced and currently hidden commands
|
|
528
577
|
|
|
529
|
-
|
|
530
|
-
browser4-cli htmlsnapshot get text "#productTitle"
|
|
531
|
-
browser4-cli htmlsnapshot get html "#main-content"
|
|
532
|
-
browser4-cli htmlsnapshot get attr "a.product-link" href
|
|
533
|
-
browser4-cli htmlsnapshot get html "body" --page 2
|
|
534
|
-
browser4-cli htmlsnapshot get html --all
|
|
535
|
-
```
|
|
578
|
+
These commands exist in the CLI but are intentionally kept out of the default public help.
|
|
536
579
|
|
|
537
|
-
|
|
580
|
+
| Command | Description |
|
|
581
|
+
|---|---|
|
|
582
|
+
| `upload <ref> <file>` | Upload one or multiple files to a file input. |
|
|
583
|
+
| `act <description>` | Experimental natural-language action translator that turns plain text into a browser command and runs it. |
|
|
538
584
|
|
|
539
|
-
|
|
540
|
-
Supports `--offset N` and `--limit N` for element-level pagination, plus
|
|
541
|
-
`--page N`, `--page-size N`, `--all` for output pagination. `get all html` is
|
|
542
|
-
paginated at 2000 lines by default; `get all text` is not paginated by default.
|
|
585
|
+
### Timeout environment variables
|
|
543
586
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
587
|
+
| Variable | Default | Used for |
|
|
588
|
+
|---|---:|---|
|
|
589
|
+
| `BROWSER4_CLI_HTTP_TIMEOUT_SECS` | `30` | most commands |
|
|
590
|
+
| `BROWSER4_CLI_INPUT_TIMEOUT_SECS` | `90` | `type`, `fill`, and other slower input workflows |
|
|
591
|
+
| `BROWSER4_CLI_NAVIGATION_TIMEOUT_SECS` | `120` | `goto`, `reload`, `go-back`, `go-forward` |
|
|
549
592
|
|
|
550
593
|
```bash
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
browser4-cli htmlsnapshot get all text "p" --page-size 500
|
|
594
|
+
export BROWSER4_CLI_INPUT_TIMEOUT_SECS=180
|
|
595
|
+
export BROWSER4_CLI_NAVIGATION_TIMEOUT_SECS=300
|
|
554
596
|
```
|
|
555
597
|
|
|
556
|
-
|
|
598
|
+
### State persistence
|
|
557
599
|
|
|
558
|
-
|
|
559
|
-
`@url` as a placeholder for the target page URL (unquoted โ the server handles
|
|
560
|
-
escaping).
|
|
561
|
-
|
|
562
|
-
**Recommended:** Write queries to a `.sql` file to avoid shell escaping issues.
|
|
563
|
-
Prefix the `--sql` value with `@` to read from a file. Use `--sql-stdin` for
|
|
564
|
-
piped/scripted workflows, or `--sql-base64` for transport-safe encoded queries.
|
|
565
|
-
|
|
566
|
-
```bash
|
|
567
|
-
# From a file (recommended โ no shell escaping)
|
|
568
|
-
cat > query.sql << 'SQLEOF'
|
|
569
|
-
SELECT
|
|
570
|
-
dom_base_uri(dom) AS url,
|
|
571
|
-
dom_first_text(dom, 'h1') AS title
|
|
572
|
-
FROM load_and_select(@url, ':root')
|
|
573
|
-
SQLEOF
|
|
574
|
-
browser4-cli htmlsnapshot query --sql @query.sql
|
|
600
|
+
CLI state lives under `~/.browser4` unless overridden.
|
|
575
601
|
|
|
576
|
-
|
|
577
|
-
|
|
602
|
+
- default session: `~/.browser4/cli-state.json`
|
|
603
|
+
- named sessions: `~/.browser4/sessions/<name>.json`
|
|
604
|
+
- loops: `~/.browser4/loops/<name>.json`
|
|
578
605
|
|
|
579
|
-
|
|
580
|
-
browser4-cli htmlsnapshot query --sql "$(base64 -w0 query.sql)" --sql-base64
|
|
606
|
+
The runtime bundle is stored separately in a platform-conventional application-data directory, so clearing session state does not force a re-download of Browser4 itself.
|
|
581
607
|
|
|
582
|
-
|
|
583
|
-
browser4-cli htmlsnapshot query --sql "
|
|
584
|
-
SELECT dom_base_uri(dom) AS url, dom_first_text(dom, 'h1') AS title
|
|
585
|
-
FROM load_and_select(@url, ':root')
|
|
586
|
-
"
|
|
587
|
-
```
|
|
608
|
+
---
|
|
588
609
|
|
|
589
|
-
|
|
610
|
+
## ๐ Build from Source
|
|
590
611
|
|
|
591
|
-
|
|
612
|
+
**Prerequisites:** Git, JDK 17+ (21+ recommended), Chrome/Chromium, and PowerShell 7 (Linux/macOS only). For the full prerequisites table, platform-specific tools, and Chrome auto-detection paths, see [Build from Source](docs/build-from-source.md).
|
|
592
613
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
#### htmlsnapshot summary
|
|
614
|
+
1. **Clone the repository**
|
|
615
|
+
```shell
|
|
616
|
+
git clone https://github.com/platonai/Browser4.git
|
|
617
|
+
cd Browser4
|
|
618
|
+
```
|
|
599
619
|
|
|
600
|
-
|
|
601
|
-
content nodes, repeated lists, tables, and stats โ typically <1% of the original
|
|
602
|
-
HTML size.
|
|
620
|
+
2. **Configure your LLM API key**
|
|
603
621
|
|
|
604
|
-
|
|
605
|
-
browser4-cli htmlsnapshot summary
|
|
606
|
-
```
|
|
622
|
+
> Edit [application.properties](application.properties) and add your API key, or set environment variables. See [LLM Configuration](#llm-configuration) for supported providers and variable names.
|
|
607
623
|
|
|
608
|
-
|
|
624
|
+
3. **Build the project**
|
|
625
|
+
```shell
|
|
626
|
+
./mvnw -DskipTests
|
|
627
|
+
```
|
|
609
628
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
629
|
+
4. **Build and run the CLI (from source)**
|
|
630
|
+
```shell
|
|
631
|
+
# Build the Rust CLI (requires Rust toolchain)
|
|
632
|
+
cd cli/browser4-cli && cargo build --release
|
|
613
633
|
|
|
614
|
-
|
|
615
|
-
browser4-cli
|
|
616
|
-
browser4-cli htmlsnapshot grep -F -C 2 "404 Not Found"
|
|
617
|
-
browser4-cli htmlsnapshot grep --selector main "Submit"
|
|
618
|
-
browser4-cli htmlsnapshot grep --all "TODOs"
|
|
619
|
-
```
|
|
634
|
+
# Or run directly without installing:
|
|
635
|
+
cargo run --manifest-path cli/browser4-cli/Cargo.toml -- --help
|
|
620
636
|
|
|
621
|
-
|
|
637
|
+
# Add --quiet to suppress Cargo build-status output:
|
|
638
|
+
cargo run --quiet --manifest-path cli/browser4-cli/Cargo.toml -- <command>
|
|
622
639
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
640
|
+
# Or install globally:
|
|
641
|
+
cd cli/browser4-cli && cargo install --path .
|
|
642
|
+
```
|
|
643
|
+
> On Windows, prefix the command with `chcp 65001 >nul &&` for proper UTF-8 output.
|
|
644
|
+
> See [Build from Source](docs/build-from-source.md) for full platform-specific instructions.
|
|
627
645
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
```
|
|
646
|
+
**Dev-mode wrappers (no install needed):** The repo root provides shell wrappers
|
|
647
|
+
that auto-build from source. Use `./b4w.ps1 <command>` (PowerShell),
|
|
648
|
+
`./b4w.sh <command>` (Git Bash / Linux / macOS), or `./b4w.bat <command>`
|
|
649
|
+
(CMD) โ all accept the same arguments as the installed `browser4-cli` binary.
|
|
633
650
|
|
|
634
651
|
---
|
|
635
652
|
|
|
636
|
-
|
|
653
|
+
๐ฌ YouTube:
|
|
654
|
+
[](https://www.youtube.com/watch?v=_BcryqWzVMI)
|
|
637
655
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
| Provider | Environment Variables |
|
|
642
|
-
|---|---|
|
|
643
|
-
| DeepSeek | `DEEPSEEK_API_KEY` |
|
|
644
|
-
| OpenRouter | `OPENROUTER_API_KEY`, `OPENROUTER_MODEL_NAME`, `OPENROUTER_BASE_URL` |
|
|
645
|
-
| Volcengine (ByteDance) | `VOLCENGINE_API_KEY`, `VOLCENGINE_MODEL_NAME`, `VOLCENGINE_BASE_URL` |
|
|
646
|
-
| OpenAI-compatible | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
|
|
647
|
-
| Aliyun Qwen (DashScope) | `OPENAI_API_KEY`, `OPENAI_MODEL_NAME`, `OPENAI_BASE_URL` |
|
|
648
|
-
|
|
649
|
-
Example:
|
|
650
|
-
|
|
651
|
-
```bash
|
|
652
|
-
export DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
If no valid LLM key is configured, AI commands fail fast with a clear error at startup.
|
|
656
|
+
๐บ Bilibili:
|
|
657
|
+
[https://www.bilibili.com/video/BV1kM2rYrEFC](https://www.bilibili.com/video/BV1kM2rYrEFC)
|
|
656
658
|
|
|
657
659
|
---
|
|
658
660
|
|
|
659
|
-
|
|
661
|
+
## Architecture
|
|
660
662
|
|
|
661
|
-
The `agent` subcommands submit natural-language tasks that the Browser4 backend
|
|
662
|
-
executes autonomously โ it plans, browses, and returns a result.
|
|
663
|
-
|
|
664
|
-
```
|
|
665
|
-
browser4-cli agent run <task>
|
|
666
|
-
browser4-cli agent status <id>
|
|
667
|
-
browser4-cli agent result <id>
|
|
668
663
|
```
|
|
669
|
-
|
|
670
|
-
#### agent run
|
|
671
|
-
|
|
672
|
-
Submit an asynchronous natural-language task. Returns immediately with a task ID.
|
|
673
|
-
|
|
674
|
-
```bash
|
|
675
|
-
browser4-cli agent run "Open browser4.io and summarize the hero section"
|
|
676
|
-
# โ Task submitted: agent-task-1
|
|
677
|
-
# โ Use 'browser4-cli agent status agent-task-1' to check progress.
|
|
664
|
+
browser4-cli (Rust) โโMCP over HTTPโโโถ browser4-rest (Kotlin/Spring) โโโถ PulsarWebDriver (Kotlin/CDP)
|
|
678
665
|
```
|
|
679
666
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
```bash
|
|
685
|
-
browser4-cli agent status agent-task-1
|
|
686
|
-
```
|
|
687
|
-
|
|
688
|
-
#### agent result
|
|
689
|
-
|
|
690
|
-
Fetch the completed task result.
|
|
667
|
+
- **CLI** (`cli/browser4-cli`) โ native Rust binary, talks to the backend via MCP tool calls
|
|
668
|
+
- **Backend** (`browser4-rest`) โ Spring Boot server, dispatches MCP tools to browser drivers
|
|
669
|
+
- **Browser driver** (`browser4-core/browser4-browser`) โ wraps Chrome DevTools Protocol
|
|
670
|
+
- **Agent tools** (`browser4-agentic`) โ maps MCP tool names to browser automation methods
|
|
691
671
|
|
|
692
|
-
|
|
693
|
-
browser4-cli agent result agent-task-1
|
|
694
|
-
```
|
|
672
|
+
## ๐ฆ Modules Overview
|
|
695
673
|
|
|
696
|
-
|
|
697
|
-
|
|
674
|
+
| Module | Description |
|
|
675
|
+
|---|----------------------------------------------------------------------|
|
|
676
|
+
| `cli/browser4-cli` | Rust CLI โ fast, native binary for browser automation |
|
|
677
|
+
| `skills/browser4-cli` | AI agent skill definitions (SKILL.md) |
|
|
678
|
+
| `browser4-core` | Core engine: sessions, scheduling, DOM, browser control |
|
|
679
|
+
| `browser4-dependencies` | BOM and dependency version alignment |
|
|
680
|
+
| `browser4-tools` | Operational tools and launch helpers |
|
|
681
|
+
| `browser4-agentic` | AI agents, MCP integration, skill registration |
|
|
682
|
+
| `browser4-agent-tools` | High-level agent tools: scraping, crawling, stateful page interaction |
|
|
683
|
+
| `browser4-rest` | Spring Boot REST layer & command endpoints |
|
|
684
|
+
| `browser4-apps/browser4-standalone` | Product packaging โ unified launcher (`target/Browser4.jar`) |
|
|
685
|
+
| `examples/browser4-examples` | Runnable examples and demos |
|
|
686
|
+
| `browser4-tests` | E2E, integration, and scenario test suites |
|
|
687
|
+
| `cdp-protocol` | Chrome DevTools Protocol JSON definitions |
|
|
688
|
+
| `coworker/` | Builtin AI coworker |
|
|
698
689
|
|
|
699
690
|
---
|
|
700
691
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
Swarm mode coordinates multiple browser contexts in parallel for high-throughput
|
|
704
|
-
scraping and data extraction.
|
|
705
|
-
|
|
706
|
-
```
|
|
707
|
-
browser4-cli swarm create [options]
|
|
708
|
-
browser4-cli swarm submit [url] [options]
|
|
709
|
-
browser4-cli swarm query <url> --sql <query>
|
|
710
|
-
browser4-cli swarm status <id>
|
|
711
|
-
browser4-cli swarm result <id>
|
|
712
|
-
```
|
|
692
|
+
## ๐งช Test Fixture Server (MockSite)
|
|
713
693
|
|
|
714
|
-
|
|
694
|
+
Browser4 includes a lightweight **MockSite** server that serves static HTML pages for testing and demos. Start it from the repository root:
|
|
715
695
|
|
|
716
|
-
|
|
696
|
+
**Windows:** `./bin/test.ps1 mock-site -Dmock.site.port=18080`
|
|
697
|
+
**Linux/macOS:** `./bin/test.sh mock-site -Dmock.site.port=18080`
|
|
717
698
|
|
|
718
|
-
|
|
719
|
-
|---|---|---|
|
|
720
|
-
| `--profile-mode` | `SEQUENTIAL` | Profile mode: `SEQUENTIAL` or `TEMPORARY` |
|
|
721
|
-
| `--max-open-tabs` | `8` | Max open tabs per browser context |
|
|
722
|
-
| `--max-browser-contexts` | `2` | Number of isolated browser environments |
|
|
723
|
-
| `--display-mode` | โ | Display mode: `GUI`, `HEADLESS`, `SUPERVISED` |
|
|
724
|
-
|
|
725
|
-
```bash
|
|
726
|
-
browser4-cli swarm create \
|
|
727
|
-
--profile-mode TEMPORARY \
|
|
728
|
-
--max-open-tabs 12 \
|
|
729
|
-
--max-browser-contexts 3 \
|
|
730
|
-
--display-mode HEADLESS
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
#### swarm submit
|
|
734
|
-
|
|
735
|
-
Submit URLs as scrape jobs. Accepts a direct URL, a `--seed-file` (one URL per
|
|
736
|
-
line; `#` comments and blank lines ignored), or both.
|
|
737
|
-
|
|
738
|
-
| Option | Description |
|
|
739
|
-
|---|---|
|
|
740
|
-
| `--seed-file <path>` | File of URLs to submit |
|
|
741
|
-
| `--sql <query>` | X-SQL query (inline or `@file.sql`). Sends to query API instead of submit. |
|
|
742
|
-
| `--deadline <ISO 8601>` | Task completion deadline |
|
|
743
|
-
| `--expires <duration>` | Cache expiration (e.g. `1d`, `1h`) |
|
|
744
|
-
| `--refresh` | Force fresh fetch, ignore cache |
|
|
745
|
-
| `--parse` | Parse page immediately after fetching |
|
|
746
|
-
|
|
747
|
-
```bash
|
|
748
|
-
# Submit URLs from a file
|
|
749
|
-
browser4-cli swarm submit --seed-file ./urls.txt \
|
|
750
|
-
--deadline 2026-03-30T00:00:00Z \
|
|
751
|
-
--expires 1d --refresh
|
|
752
|
-
|
|
753
|
-
# Submit with inline X-SQL
|
|
754
|
-
browser4-cli swarm submit "https://www.amazon.com/dp/B08PP5MSVB" --sql "
|
|
755
|
-
SELECT
|
|
756
|
-
dom_base_uri(dom) AS url,
|
|
757
|
-
dom_first_text(dom, '#productTitle') AS title
|
|
758
|
-
FROM load_and_select(@url, 'body')
|
|
759
|
-
"
|
|
760
|
-
|
|
761
|
-
# Submit with X-SQL from a file
|
|
762
|
-
browser4-cli swarm submit "https://www.amazon.com/dp/B08PP5MSVB" --sql @query.sql
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
#### swarm query
|
|
766
|
-
|
|
767
|
-
Run an X-SQL query against loaded webpages. `--sql` is required. Supports a
|
|
768
|
-
direct URL, `--seed-file`, or both โ runs the same query against each. Also
|
|
769
|
-
accepts `--deadline`, `--expires`, `--refresh`.
|
|
770
|
-
|
|
771
|
-
```bash
|
|
772
|
-
# Inline X-SQL
|
|
773
|
-
browser4-cli swarm query "https://www.amazon.com/dp/B08PP5MSVB" --sql "
|
|
774
|
-
SELECT dom_first_text(dom, '#productTitle') AS title
|
|
775
|
-
FROM load_and_select(@url, 'body')
|
|
776
|
-
"
|
|
777
|
-
|
|
778
|
-
# From a file, with seed URLs
|
|
779
|
-
browser4-cli swarm query --sql @query.sql --seed-file ./urls.txt --refresh
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
#### swarm status / swarm result
|
|
783
|
-
|
|
784
|
-
Poll and fetch results โ same pattern as `agent status` / `agent result`.
|
|
785
|
-
|
|
786
|
-
```bash
|
|
787
|
-
browser4-cli swarm status scrape-task-4
|
|
788
|
-
browser4-cli swarm result scrape-task-4
|
|
789
|
-
```
|
|
699
|
+
Key demo pages are served at `http://localhost:18080/generated/`. For the full page listing, environment variables, Python fallback, and Maven-based launch, see [MockSite](docs/mocksite.md). For the test taxonomy and tagging system, see [Test Taxonomy](docs/TESTING.md).
|
|
790
700
|
|
|
791
701
|
---
|
|
792
702
|
|
|
793
|
-
|
|
703
|
+
## ๐ค Support & Community
|
|
794
704
|
|
|
795
|
-
|
|
705
|
+
Join our community for support, feedback, and collaboration!
|
|
796
706
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
707
|
+
- **GitHub Discussions**: Engage with developers and users.
|
|
708
|
+
- **Issue Tracker**: Report bugs or request features.
|
|
709
|
+
- **Social Media**: Follow us for updates and news.
|
|
800
710
|
|
|
801
|
-
|
|
802
|
-
|---|---|---|
|
|
803
|
-
| `-d`, `--depth` | `1` | Maximum crawl depth |
|
|
804
|
-
| `-ol`, `--out-link-selector` | โ | CSS selector to extract links from each page |
|
|
805
|
-
| `-olp`, `--out-link-pattern` | `.+` | Regex filter for extracted links |
|
|
806
|
-
| `-tl`, `--top-links` | `20` | Max links extracted per page |
|
|
807
|
-
| `-a`, `--args` | โ | Additional LoadOptions passthrough (e.g. `-a "-nMaxRetry 5"`) |
|
|
808
|
-
| `--refresh` | โ | Force fresh fetch |
|
|
809
|
-
| `--parse` | โ | Parse pages immediately after fetching |
|
|
810
|
-
| `--expires` | โ | Cache expiration (e.g. `1d`, `1h`, `30m`) |
|
|
811
|
-
| `-p`, `--priority` | โ | Queue priority (lower = higher) |
|
|
812
|
-
| `--ignore-url-query` | โ | Strip query params during URL normalization |
|
|
813
|
-
| `--no-norm` | โ | Disable URL normalization |
|
|
814
|
-
| `--readonly` | โ | Non-destructive mode |
|
|
815
|
-
| `--page-load-timeout` | โ | Max wait for each page load |
|
|
816
|
-
| `-bg`, `--background` | โ | Submit crawl and return immediately; use `crawl list` to track |
|
|
817
|
-
|
|
818
|
-
```bash
|
|
819
|
-
# Depth 1: extract all links from homepage, load each linked page
|
|
820
|
-
browser4-cli crawl "https://example.com" --out-link-selector "a[href]"
|
|
821
|
-
|
|
822
|
-
# Depth 2: follow product links, filter by pattern
|
|
823
|
-
browser4-cli crawl "https://shop.example.com" \
|
|
824
|
-
--depth 2 \
|
|
825
|
-
--out-link-selector "a.product-link" \
|
|
826
|
-
--out-link-pattern "/product/" \
|
|
827
|
-
--top-links 10
|
|
828
|
-
|
|
829
|
-
# Deep crawl with refresh and content storage
|
|
830
|
-
browser4-cli crawl "https://example.com" --depth 3 --refresh
|
|
831
|
-
|
|
832
|
-
# Background crawl โ submit and return immediately
|
|
833
|
-
browser4-cli crawl "https://example.com" -ol "a[href]" --background
|
|
834
|
-
browser4-cli crawl list
|
|
835
|
-
```
|
|
711
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
836
712
|
|
|
837
713
|
---
|
|
838
714
|
|
|
839
|
-
##
|
|
715
|
+
## ๐ Documentation
|
|
840
716
|
|
|
841
|
-
|
|
842
|
-
element is labeled with a ref like `e15`. Pass this ref to any interaction
|
|
843
|
-
command:
|
|
717
|
+
Comprehensive documentation is available in the `docs/` directory and on our [GitHub Pages site](https://platonai.github.io/browser4/).
|
|
844
718
|
|
|
845
|
-
|
|
846
|
-
browser4-cli snapshot # see e15 is the search input
|
|
847
|
-
browser4-cli click e15 # click it
|
|
848
|
-
browser4-cli type "query" e15 # type into it
|
|
849
|
-
```
|
|
850
|
-
|
|
851
|
-
You can also use CSS selectors (e.g. `#search`, `.btn-primary`,
|
|
852
|
-
`input[name=email]`) anywhere a ref is accepted.
|
|
719
|
+
---
|
|
853
720
|
|
|
854
|
-
##
|
|
721
|
+
## ๐ง Proxy Configuration - Unblock Website Access
|
|
855
722
|
|
|
856
|
-
|
|
723
|
+
<details>
|
|
857
724
|
|
|
858
|
-
|
|
859
|
-
- Named sessions (`-s <name>`): `~/.browser4/sessions/<name>.json`
|
|
725
|
+
Set the environment variable `PROXY_ROTATION_URL` to the rotation URL provided by your proxy service provider:
|
|
860
726
|
|
|
861
|
-
|
|
862
|
-
|
|
727
|
+
```shell
|
|
728
|
+
export PROXY_ROTATION_URL=https://your-proxy-provider.com/rotation-endpoint
|
|
729
|
+
```
|
|
863
730
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
require re-downloading:
|
|
731
|
+
Each time you access this rotation URL, it should return a response containing one or more fresh proxy IPs.
|
|
732
|
+
If you need this type of URL, please contact your proxy service provider.
|
|
867
733
|
|
|
868
|
-
|
|
869
|
-
|---|---|
|
|
870
|
-
| Linux | `~/.local/share/browser4/runtime/<version>/` |
|
|
871
|
-
| macOS | `~/Library/Application Support/browser4/runtime/<version>/` |
|
|
872
|
-
| Windows | `%APPDATA%/browser4/runtime/<version>/` |
|
|
734
|
+
</details>
|
|
873
735
|
|
|
874
|
-
|
|
736
|
+
---
|
|
875
737
|
|
|
876
738
|
## License
|
|
877
739
|
|
|
878
|
-
Apache
|
|
740
|
+
Apache 2.0 License. See [LICENSE](LICENSE) for details.
|