@xbrowser/cli 1.34.0 → 1.36.0
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 +137 -80
- package/dist/{browser-ZWEJ663M.js → browser-IEZOLTHA.js} +3 -3
- package/dist/{browser-GXL6V2JW.js → browser-NHQDQRXB.js} +3 -2
- package/dist/{browser-X7LO42UI.js → browser-XELRNYBL.js} +3 -3
- package/dist/cdp-driver-CCG3OJUQ.js +49 -0
- package/dist/{cdp-driver-GCFEMRFJ.js → cdp-driver-HBMCD7NU.js} +2 -2
- package/dist/{cdp-driver-QOUSRPR2.js → cdp-driver-MJD7YIQI.js} +2 -2
- package/dist/{cdp-driver-4MNHDU2J.js → cdp-driver-YJU4GRSV.js} +196 -95
- package/dist/chunk-2IOFJ6A3.js +149 -0
- package/dist/chunk-3SZTCI33.js +147 -0
- package/dist/{chunk-VYTQLZAX.js → chunk-5UXRFNXG.js} +28 -2
- package/dist/{chunk-NAIHOVDZ.js → chunk-63526WET.js} +2 -8
- package/dist/{chunk-YIL44YDX.js → chunk-6DS3T6UK.js} +196 -95
- package/dist/{chunk-J4NOL5XX.js → chunk-7KVH6MQG.js} +1099 -204
- package/dist/{chunk-N7DFS4V7.js → chunk-ENTENDF5.js} +9 -3
- package/dist/{chunk-R57Z5KZX.js → chunk-GVJ2UY65.js} +1078 -185
- package/dist/{chunk-3E6VVMK2.js → chunk-GYGVHWG3.js} +272 -1460
- package/dist/{chunk-2KPI5GKP.js → chunk-IYCB2KJL.js} +2 -8
- package/dist/chunk-KSB4PMCY.js +1380 -0
- package/dist/{chunk-RMYKVZIZ.js → chunk-L6QJUB33.js} +28 -2
- package/dist/{chunk-TBJUSUKF.js → chunk-NBT2CE3H.js} +140 -96
- package/dist/{chunk-DZ6XEPAH.js → chunk-PGEZJ6V3.js} +9 -3
- package/dist/chunk-RGL2YTWQ.js +64 -0
- package/dist/chunk-RL5FFY2Q.js +150 -0
- package/dist/{chunk-43TEMG4U.js → chunk-SBMVECDS.js} +3 -1
- package/dist/{chunk-BND5O5KC.js → chunk-SQLICOPZ.js} +177 -240
- package/dist/{chunk-O5PASNI7.js → chunk-UUW5EGES.js} +139 -237
- package/dist/{chunk-SH6OTPXN.js → chunk-WGWPWNIA.js} +78 -17
- package/dist/chunk-YW4BIJQL.js +489 -0
- package/dist/{chunk-R7AG7ONI.js → chunk-ZCZELQCS.js} +196 -95
- package/dist/chunk-ZR4NHTUV.js +39 -0
- package/dist/cli.js +2284 -307
- package/dist/convert-JNOM6H6A.js +490 -0
- package/dist/{convert-R3XXYKC6.js → convert-K6TLQEPX.js} +5 -3
- package/dist/{daemon-client-7D6EZNOE.js → daemon-client-AKQK5IIB.js} +79 -18
- package/dist/{daemon-client-HEGAXWGK.js → daemon-client-BBPQWLUX.js} +7 -1
- package/dist/daemon-main.js +2305 -164
- package/dist/human-interaction-BGAZC3JR.js +12 -0
- package/dist/human-interaction-TPKPEE7A.js +11 -0
- package/dist/human-interaction-ZSD3IX6Q.js +12 -0
- package/dist/index.d.ts +251 -97
- package/dist/index.js +2929 -298
- package/dist/{launcher-TOLF23ET.js → launcher-AUJK5QQM.js} +1 -1
- package/dist/{launcher-ZYB32LSZ.js → launcher-QBAZ6F5L.js} +1 -1
- package/dist/mistake-ledger-2B4N54CO.js +29 -0
- package/dist/{recovery-ORHJSBDN.js → recovery-5AGY7CV3.js} +4 -5
- package/dist/{recovery-XDKN63O5.js → recovery-7NRRHLS4.js} +2 -2
- package/dist/{recovery-JFGV3DBX.js → recovery-TIBRFGRP.js} +2 -2
- package/dist/run-routes-64IBBVOX.js +24 -0
- package/dist/run-routes-FG4LIACU.js +26 -0
- package/dist/{server-5U56MQD2.js → server-K22LJBO2.js} +5 -4
- package/dist/{server-R4OYD7ZC.js → server-ZHZDJJMG.js} +5 -3
- package/dist/{session-recorder-RUNQOJ7T.js → session-recorder-CNTY5KXF.js} +1 -1
- package/dist/{session-recorder-N7VEKJVW.js → session-recorder-KMKSQWEP.js} +1 -1
- package/dist/{session-replayer-GHEFFNGV.js → session-replayer-4TCLQI76.js} +1 -1
- package/dist/viewer-routes-CEO7HWCB.js +11 -0
- package/package.json +3 -2
- package/dist/chunk-ETCO4SNK.js +0 -206
- package/dist/chunk-QCV2PI7U.js +0 -184
- package/dist/convert-LB3GJTLR.js +0 -207
- package/dist/human-interaction-ISMMOJOK.js +0 -8
- package/dist/human-interaction-STTZZZ5N.js +0 -8
- package/dist/human-interaction-UXFYV7DU.js +0 -8
package/README.md
CHANGED
|
@@ -1,33 +1,74 @@
|
|
|
1
1
|
# xbrowser
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Scraping a page, filling in a form, or grabbing a screenshot shouldn't take a Playwright project — environment setup, a script, and selectors to maintain.**
|
|
4
|
+
> **xbrowser turns each one into a single command line.** No code to write: run it in your terminal, chain steps together, or let your AI agent call it.
|
|
5
|
+
>
|
|
6
|
+
> **抓取一个页面、填写一张表单、截一张图,不该为此搭一个 Playwright 工程——配环境、写脚本,还要长期维护选择器。**
|
|
7
|
+
> **xbrowser 把每一件事都变成一行命令。** 不用写代码:终端里直接跑,多步用命令链串起来,也可以让 AI Agent 直接调用。
|
|
4
8
|
|
|
5
9
|
[](https://github.com/dyyz1993/xbrowser/actions)
|
|
6
10
|
[](https://codecov.io/gh/dyyz1993/xbrowser)
|
|
7
11
|
[](https://www.npmjs.com/package/@xbrowser/cli)
|
|
8
12
|
[](https://opensource.org/licenses/MIT)
|
|
9
13
|
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **One command instead of a script** — 59 built-in commands (`scrape`, `click`, `fill`, `search`, `screenshot`, …), each a one-liner
|
|
17
|
+
- **Command chains** — string steps together with `&&`, `->`, `,`, `+`, `||`, or pipe and heredoc a whole workflow
|
|
18
|
+
- **Record & replay** — record a flow once to YAML, replay it in CI or export it as a standalone Playwright script; stale selectors re-resolve themselves ([self-healing replay](docs/recording.md))
|
|
19
|
+
- **126 site plugins** — publish, search, and collect on real sites (Dev.to, Juejin, CSDN, GitHub, …), one plugin per site: `xbrowser plugin install <name>`, or scaffold your own with `xbrowser create my-plugin`
|
|
20
|
+
- **Built for AI agents** — built-in MCP server (`xbrowser mcp`), `--json` output, token-friendly page snapshots
|
|
21
|
+
- **Use the browser you already have** — attach to a running Chrome over CDP and keep your logins; multi-session, daemon mode, and a [stealth layer](docs/stealth.md)
|
|
22
|
+
|
|
10
23
|
## 特性
|
|
11
24
|
|
|
12
|
-
-
|
|
13
|
-
- **命令链** — 用
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
- **一条命令替代一个脚本** — 59 个内置命令(`scrape`、`click`、`fill`、`search`、`screenshot` 等),每个都是一行
|
|
26
|
+
- **命令链** — 用 `&&`、`->`、`,`、`+`、`||` 串联多步,整条流程也可以走管道和 Heredoc
|
|
27
|
+
- **录制 / 回放** — 录一次存成 YAML,CI 里随时回放,也可导出成独立的 Playwright 脚本;选择器失效会自动重新定位([自愈回放](docs/recording.md))
|
|
28
|
+
- **126 个站点插件** — 在真实站点上发布、搜索、采集(Dev.to、掘金、CSDN、GitHub 等),一个站点一个插件:`xbrowser plugin install <name>` 安装,或用 `xbrowser create my-plugin` 脚手架写自己的
|
|
29
|
+
- **为 AI Agent 而生** — 内置 MCP Server(`xbrowser mcp`)、`--json` 输出、对 token 友好的页面快照
|
|
30
|
+
- **复用你已有的浏览器** — 通过 CDP 连接正在运行的 Chrome、保留登录态;多会话并行、Daemon 常驻、[Stealth 伪装层](docs/stealth.md)
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install — needs Node.js >= 18 and a local Chrome or Chromium (auto-detected on macOS/Linux)
|
|
36
|
+
npm install -g @xbrowser/cli
|
|
37
|
+
|
|
38
|
+
# Three steps, one line, zero scripts
|
|
39
|
+
xbrowser "goto https://example.com && title && screenshot"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
[OK] goto https://example.com
|
|
44
|
+
url: https://example.com
|
|
45
|
+
status: 200
|
|
46
|
+
[OK] title
|
|
47
|
+
title: Example Domain
|
|
48
|
+
[OK] screenshot
|
|
49
|
+
output: …/xbrowser/screenshots/screenshot-….png
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Want your AI agent to drive the browser instead?
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
claude mcp add xbrowser -- xbrowser mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Full guide: [快速开始](#快速开始) · More recipes: [Use Cases](#use-cases)
|
|
21
59
|
|
|
22
60
|
## Use Cases
|
|
23
61
|
|
|
24
62
|
**Web Scraping & Data Extraction**
|
|
25
63
|
```bash
|
|
26
64
|
# Scrape any page to Markdown — no Playwright scripts needed
|
|
27
|
-
xbrowser scrape https://news.ycombinator.com --
|
|
65
|
+
xbrowser scrape https://news.ycombinator.com --format markdown
|
|
66
|
+
|
|
67
|
+
# Or pull the tables out as structured data
|
|
68
|
+
xbrowser scrape https://news.ycombinator.com --mode smart
|
|
28
69
|
|
|
29
70
|
# Crawl an entire site
|
|
30
|
-
xbrowser crawl https://example.com --
|
|
71
|
+
xbrowser crawl https://example.com --maxDepth 3 --format markdown
|
|
31
72
|
```
|
|
32
73
|
|
|
33
74
|
**Search Engine Automation**
|
|
@@ -36,24 +77,26 @@ xbrowser crawl https://example.com --max-depth 3 --output json
|
|
|
36
77
|
xbrowser search "best headless browser CLI" --engine google --limit 10 --json
|
|
37
78
|
|
|
38
79
|
# Time-filtered search
|
|
39
|
-
xbrowser search "playwright alternative 2025" --engine bing --
|
|
80
|
+
xbrowser search "playwright alternative 2025" --engine bing --recency month
|
|
40
81
|
```
|
|
41
82
|
|
|
42
83
|
**Browser Automation for AI Agents**
|
|
43
84
|
```bash
|
|
44
85
|
# Record browser actions, replay in CI/CD
|
|
45
|
-
xbrowser record --
|
|
86
|
+
xbrowser record start --url https://example.com --name my-flow
|
|
87
|
+
# …click through the flow in the browser, then:
|
|
88
|
+
xbrowser record stop --output workflow.yaml
|
|
46
89
|
xbrowser replay workflow.yaml
|
|
47
90
|
|
|
48
91
|
# Chain commands for complex workflows
|
|
49
|
-
xbrowser "goto https://
|
|
92
|
+
xbrowser "goto https://news.ycombinator.com && wait .titleline && text --selector '.titleline > a'"
|
|
50
93
|
```
|
|
51
94
|
|
|
52
95
|
**SEO & Backlink Automation**
|
|
53
96
|
```bash
|
|
54
97
|
# Publish articles to SEO platforms via site plugins
|
|
55
|
-
xbrowser devto publish --file article.md
|
|
56
|
-
xbrowser juejin publish --file article.md
|
|
98
|
+
xbrowser devto publish --title "My article" --file article.md
|
|
99
|
+
xbrowser juejin publish --title "My article" --file article.md
|
|
57
100
|
# (Each platform has its own plugin — run `xbrowser plugin list` to see available)
|
|
58
101
|
```
|
|
59
102
|
|
|
@@ -68,8 +111,8 @@ xbrowser content draft --case self-healing-replay --lang zh
|
|
|
68
111
|
# Render an OG cover image with the browser itself — zero imaging libraries
|
|
69
112
|
xbrowser "set-viewport 1200 630 && content cover --title 'Self-Healing Replay' --output cover.png"
|
|
70
113
|
|
|
71
|
-
# Publish through
|
|
72
|
-
xbrowser devto publish --file output/content/self-healing-replay-en.md --tags "typescript,automation"
|
|
114
|
+
# Publish through a platform plugin
|
|
115
|
+
xbrowser devto publish --title "Self-Healing Replay" --file output/content/self-healing-replay-en.md --tags "typescript,automation"
|
|
73
116
|
```
|
|
74
117
|
The full write → cover → publish loop that promotes xbrowser is itself built on xbrowser commands.
|
|
75
118
|
|
|
@@ -86,7 +129,7 @@ npm install -g @xbrowser/cli
|
|
|
86
129
|
### 最低要求
|
|
87
130
|
|
|
88
131
|
- Node.js >= 18
|
|
89
|
-
- Chromium
|
|
132
|
+
- Chromium 或 Google Chrome(自动探测 macOS / Linux 常见路径,优先 `/Applications/Chromium.app/Contents/MacOS/Chromium`;其它路径用环境变量 `XBROWSER_CHROMIUM_PATH` 指定)
|
|
90
133
|
|
|
91
134
|
### 第一次使用
|
|
92
135
|
|
|
@@ -96,12 +139,12 @@ xbrowser goto https://example.com
|
|
|
96
139
|
|
|
97
140
|
# 获取页面标题
|
|
98
141
|
xbrowser title
|
|
99
|
-
# 输出: Example Domain
|
|
142
|
+
# 输出: title: Example Domain
|
|
100
143
|
|
|
101
144
|
# 获取页面文本
|
|
102
145
|
xbrowser text
|
|
103
146
|
|
|
104
|
-
#
|
|
147
|
+
# 截图(默认存到系统临时目录 …/xbrowser/screenshots,用 --output 指定路径)
|
|
105
148
|
xbrowser screenshot
|
|
106
149
|
|
|
107
150
|
# 关闭会话
|
|
@@ -171,8 +214,8 @@ xbrowser -e "goto https://example.com" -e "title"
|
|
|
171
214
|
### CDP 连接(连接已运行的浏览器)
|
|
172
215
|
|
|
173
216
|
```bash
|
|
174
|
-
# 通过 WebSocket URL
|
|
175
|
-
xbrowser --cdp ws://localhost:9222 "goto https://example.com , title"
|
|
217
|
+
# 通过 WebSocket URL 连接(<id> 取自 http://localhost:9222/json/version)
|
|
218
|
+
xbrowser --cdp ws://localhost:9222/devtools/browser/<id> "goto https://example.com , title"
|
|
176
219
|
|
|
177
220
|
# 通过端口号连接
|
|
178
221
|
xbrowser --cdp 9222 "goto https://example.com , title"
|
|
@@ -303,7 +346,6 @@ xbrowser --cdp auto "goto https://example.com , title"
|
|
|
303
346
|
|------|------|------|
|
|
304
347
|
| `eval <expression>` | 执行 JS 表达式 | `xbrowser eval "document.title"` |
|
|
305
348
|
| `eval "1 + 2"` | 计算表达式 | `xbrowser eval "1 + 2"` |
|
|
306
|
-
| `eval "(a, b) => a + b" --args 1 2` | 执行带参数的函数 | `xbrowser eval "(a, b) => a + b" --args 1 2` |
|
|
307
349
|
|
|
308
350
|
### 存储
|
|
309
351
|
|
|
@@ -357,12 +399,10 @@ xbrowser --cdp auto "goto https://example.com , title"
|
|
|
357
399
|
|
|
358
400
|
| 命令 | 说明 | 示例 |
|
|
359
401
|
|------|------|------|
|
|
360
|
-
| `convert <rec.yaml> <output>` |
|
|
361
|
-
| `convert <rec.yaml> <output.py>` | 生成 Python 脚本 | `xbrowser convert recording.yaml replay.py` |
|
|
362
|
-
| `convert <rec.yaml> <output.sh>` | 生成 Bash 脚本 | `xbrowser convert recording.yaml replay.sh` |
|
|
402
|
+
| `convert <rec.yaml> <output.py>` | 转换为 Python + Playwright 脚本 | `xbrowser convert recording.yaml replay.py` |
|
|
363
403
|
| `extract <rec.yaml>` | 提取 LLM 摘要 | `xbrowser extract recording.yaml` |
|
|
364
404
|
| `filter <in.yaml> <out.yaml>` | 过滤录制事件 | `xbrowser filter raw.yaml clean.yaml` |
|
|
365
|
-
| `filter <in.yaml> <out.yaml> --exclude scroll,
|
|
405
|
+
| `filter <in.yaml> <out.yaml> --exclude scroll,navigation` | 排除事件类型 | `xbrowser filter raw.yaml clean.yaml --exclude scroll,navigation` |
|
|
366
406
|
|
|
367
407
|
### 插件管理
|
|
368
408
|
|
|
@@ -439,8 +479,8 @@ xbrowser create my-plugin --template static --force
|
|
|
439
479
|
|
|
440
480
|
**注意**:
|
|
441
481
|
- 命令链中如果包含特殊字符(如 `#`、`>`),需要用引号包裹整个命令链或对单个参数加引号。
|
|
442
|
-
-
|
|
443
|
-
-
|
|
482
|
+
- `,`、`+`、`->`、`&&`、`||` 两边都要有空格(`goto url -> title` ✅,`goto url->title` ❌);`;` 只要求后面有空格(`goto url; title` ✅,`goto url;title` ❌)。
|
|
483
|
+
- 只在分隔符前面留空格(如 `title ,url`)不会被识别成命令链:整串按单条命令执行,后面的命令被静默忽略。
|
|
444
484
|
|
|
445
485
|
```bash
|
|
446
486
|
# 正确 — 整体引号
|
|
@@ -565,22 +605,22 @@ export default function (xcli: XCLIAPI): void {
|
|
|
565
605
|
}
|
|
566
606
|
```
|
|
567
607
|
|
|
568
|
-
###
|
|
608
|
+
### 常用插件
|
|
569
609
|
|
|
570
|
-
xbrowser
|
|
610
|
+
插件不随 npm 包分发,按需安装:`xbrowser plugin install <name>`(npm 优先,未命中时回退 xbrowser.dev 市场)。几个例子:
|
|
571
611
|
|
|
572
612
|
| 插件 | 命令 | 说明 |
|
|
573
613
|
|------|------|------|
|
|
574
614
|
| **baidu** | `search`, `hotsearch`, `suggest`, `news` | 百度搜索、热搜、建议词、新闻 |
|
|
575
|
-
| **douyin** | `
|
|
576
|
-
| **github** | `update-profile`, `add-social-link`, `create-gist`, `get-profile` | GitHub
|
|
577
|
-
| **web-automation** | `extract`, `paginate`, `fill-and-submit`, `screenshot` | 通用 Web 自动化工具 |
|
|
615
|
+
| **douyin** | `videos`, `profile`, `detail`, `comments`, `search`, `download`, `ai-subtitle` | 抖音数据采集:作品、资料、评论、下载、AI 字幕 |
|
|
616
|
+
| **github** | `update-profile`, `add-social-link`, `create-gist`, `get-profile`, `create-repo`, `edit-readme` | GitHub 个人资料与仓库管理 |
|
|
578
617
|
| **content** | `cases`, `draft`, `cover` | 内容营销:内置推广 case 渲染成文 + 浏览器自渲染封面 |
|
|
579
618
|
|
|
580
619
|
使用插件命令:
|
|
581
620
|
|
|
582
621
|
```bash
|
|
583
|
-
#
|
|
622
|
+
# 安装并使用百度搜索插件
|
|
623
|
+
xbrowser plugin install baidu
|
|
584
624
|
xbrowser goto https://www.baidu.com
|
|
585
625
|
xbrowser baidu search --query "AI 编程"
|
|
586
626
|
|
|
@@ -609,32 +649,44 @@ xbrowser record start --url https://example.com
|
|
|
609
649
|
xbrowser record stop --output recordings/my-session.yaml
|
|
610
650
|
```
|
|
611
651
|
|
|
612
|
-
录制文件格式(YAML
|
|
652
|
+
录制文件格式(YAML)——由 `xbrowser record stop` 生成,下面是删减后的真实样例:
|
|
613
653
|
|
|
614
654
|
```yaml
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
655
|
+
startUrl: https://example.com
|
|
656
|
+
sessionName: my-session
|
|
657
|
+
startedAt: "2026-11-23T14:36:13.891Z"
|
|
658
|
+
actions:
|
|
659
|
+
- id: 1
|
|
660
|
+
type: navigation
|
|
661
|
+
timestamp: 1795444573943
|
|
662
|
+
url: https://example.com
|
|
663
|
+
pageTitle: Example Domain
|
|
664
|
+
- id: 2
|
|
665
|
+
type: cdp-fill # 经 CLI 下发的 fill;页面里的手动操作记为 input / click
|
|
666
|
+
timestamp: 1795444586890
|
|
667
|
+
url: https://example.com
|
|
668
|
+
element:
|
|
669
|
+
tag: input
|
|
670
|
+
selector: "#name"
|
|
671
|
+
strategy: id
|
|
672
|
+
confidence: high
|
|
673
|
+
value: Alice
|
|
674
|
+
snapshots:
|
|
675
|
+
png: .tmp/snapshots/step-002-after.png
|
|
676
|
+
aria: "input: | button: Submit"
|
|
677
|
+
- id: 3
|
|
678
|
+
type: click
|
|
679
|
+
timestamp: 1795444589184
|
|
680
|
+
url: https://example.com
|
|
681
|
+
element:
|
|
682
|
+
tag: button
|
|
683
|
+
selector: "#submit"
|
|
684
|
+
strategy: id
|
|
685
|
+
confidence: high
|
|
686
|
+
x: 224.4
|
|
687
|
+
y: 119.4
|
|
688
|
+
network: [] # 每个请求一条:method / url / status / resourceType
|
|
689
|
+
contextChanges: [] # 导航、弹窗等上下文变化
|
|
638
690
|
```
|
|
639
691
|
|
|
640
692
|
### 回放
|
|
@@ -649,22 +701,26 @@ xbrowser replay recordings/my-session.yaml --slow-mo 100
|
|
|
649
701
|
|
|
650
702
|
### 转换为脚本
|
|
651
703
|
|
|
652
|
-
|
|
704
|
+
录制文件可转换为三种独立运行的脚本,回放的步骤相同:
|
|
653
705
|
|
|
654
706
|
```bash
|
|
655
|
-
#
|
|
656
|
-
xbrowser convert recordings/my-session.yaml replay.js
|
|
657
|
-
node replay.js
|
|
658
|
-
|
|
659
|
-
# 生成 Python + Playwright 脚本
|
|
707
|
+
# Python + Playwright
|
|
660
708
|
xbrowser convert recordings/my-session.yaml replay.py
|
|
661
|
-
python3 replay.py
|
|
709
|
+
python3 replay.py # 需要 pip install playwright && playwright install chromium
|
|
662
710
|
|
|
663
|
-
#
|
|
711
|
+
# Node.js + Playwright
|
|
712
|
+
xbrowser convert recordings/my-session.yaml replay.js
|
|
713
|
+
node replay.js # 需要 npm install playwright && npx playwright install chromium
|
|
714
|
+
|
|
715
|
+
# Bash:通过 xbrowser CLI 在同一个会话里回放,任何一步失败都会停止并关闭会话
|
|
664
716
|
xbrowser convert recordings/my-session.yaml replay.sh
|
|
665
717
|
bash replay.sh
|
|
666
718
|
```
|
|
667
719
|
|
|
720
|
+
JS / Python 脚本设置 `XBROWSER_CHROMIUM_PATH` 可以直接复用已安装的 Chrome / Chromium,不必再下载 Playwright 自带的浏览器。
|
|
721
|
+
|
|
722
|
+
转换时会把录制归一化成真正的操作步骤:同一个动作在录制里留下的多条记录(命令与页面信号各记一次、`fill` 的聚焦点击、由点击引起的跳转、滚动信号的命令回显)都只算一步。
|
|
723
|
+
|
|
668
724
|
### 提取摘要
|
|
669
725
|
|
|
670
726
|
```bash
|
|
@@ -696,11 +752,11 @@ Key operations:
|
|
|
696
752
|
### 过滤事件
|
|
697
753
|
|
|
698
754
|
```bash
|
|
699
|
-
#
|
|
700
|
-
xbrowser filter raw.yaml clean.yaml --exclude scroll
|
|
755
|
+
# 排除滚动事件
|
|
756
|
+
xbrowser filter raw.yaml clean.yaml --exclude scroll
|
|
701
757
|
|
|
702
|
-
#
|
|
703
|
-
xbrowser filter raw.yaml clean.yaml --exclude
|
|
758
|
+
# 排除滚动和导航事件
|
|
759
|
+
xbrowser filter raw.yaml clean.yaml --exclude scroll,navigation
|
|
704
760
|
```
|
|
705
761
|
|
|
706
762
|
## 配置
|
|
@@ -712,7 +768,7 @@ xbrowser filter raw.yaml clean.yaml --exclude hover_enter,hover_leave
|
|
|
712
768
|
| 变量 | 说明 | 默认值 |
|
|
713
769
|
|------|------|--------|
|
|
714
770
|
| `XBROWSER_CHROMIUM_PATH` | Chromium 可执行文件路径 | `/Applications/Chromium.app/Contents/MacOS/Chromium` |
|
|
715
|
-
| `XBROWSER_DAEMON_PORT` | Daemon 端口 | `
|
|
771
|
+
| `XBROWSER_DAEMON_PORT` | Daemon 端口 | `9224` |
|
|
716
772
|
| `XBROWSER_CDP` | 默认 CDP 连接地址(可被 `--cdp` 覆盖) | — |
|
|
717
773
|
| `XBROWSER_SESSION` | 默认会话名称(可被 `--session` 覆盖) | `default` |
|
|
718
774
|
|
|
@@ -876,7 +932,7 @@ npm run validate
|
|
|
876
932
|
| 依赖 | 用途 |
|
|
877
933
|
|------|------|
|
|
878
934
|
| **@dyyz1993/xcli-core** | CLI 框架核心(命令注册、Scope、输出格式化、插件加载) |
|
|
879
|
-
| **
|
|
935
|
+
| **ws** | CDP WebSocket 连接(浏览器驱动是自研的 `src/cdp-driver/`,不依赖 Playwright) |
|
|
880
936
|
| **zod** | 参数校验 Schema |
|
|
881
937
|
| **yaml** | 录制文件读写 |
|
|
882
938
|
|
|
@@ -885,7 +941,7 @@ npm run validate
|
|
|
885
941
|
```
|
|
886
942
|
xbrowser/
|
|
887
943
|
├── src/
|
|
888
|
-
│ ├── commands/ #
|
|
944
|
+
│ ├── commands/ # 59 个浏览器命令定义
|
|
889
945
|
│ ├── builtins/ # CLI 内置命令(config, plugin, session, create)
|
|
890
946
|
│ ├── recorder/ # 录制引擎(录制器 + 回放器)
|
|
891
947
|
│ ├── session/ # 会话管理
|
|
@@ -896,12 +952,13 @@ xbrowser/
|
|
|
896
952
|
│ ├── executor.ts # 命令执行器
|
|
897
953
|
│ ├── chain-parser.ts # 命令链解析器
|
|
898
954
|
│ ├── browser.ts # 浏览器管理(启动、CDP 连接)
|
|
955
|
+
│ ├── cdp-driver/ # 自研 CDP 驱动(连接、输入、定位器,不依赖 Playwright)
|
|
899
956
|
│ ├── context.ts # 命令上下文(BrowserCommandContext)
|
|
900
957
|
│ ├── scope.ts # Scope 定义
|
|
901
958
|
│ └── config.ts # 配置管理
|
|
902
959
|
├── bin/
|
|
903
960
|
│ └── cli.ts # CLI 入口
|
|
904
|
-
├── .xcli/plugins/ #
|
|
961
|
+
├── .xcli/plugins/ # 站点插件(126 个)
|
|
905
962
|
├── tests/ # 测试
|
|
906
963
|
└── docs/ # 文档
|
|
907
964
|
```
|
|
@@ -914,12 +971,12 @@ xbrowser/
|
|
|
914
971
|
| **Setup** | `npm i -g` — 0 config | Install + browser download | Install + browser download | Install + WebDriver + drivers |
|
|
915
972
|
| **Web Scraping** | Built-in (`scrape`, `crawl`, `map`) | Write custom scripts | Write custom scripts | Write custom scripts |
|
|
916
973
|
| **Search** | Built-in multi-engine (`search`) | No | No | No |
|
|
917
|
-
| **Plugin Ecosystem** |
|
|
974
|
+
| **Plugin Ecosystem** | 126 plugins | Limited | Limited | No |
|
|
918
975
|
| **No Code Required** | ✅ CLI commands | ❌ Must write JS/TS | ❌ Must write JS/TS | ❌ Must write code |
|
|
919
976
|
| **Headless Mode** | ✅ Default | ✅ | ✅ | ✅ |
|
|
920
977
|
| **Record/Replay** | ✅ Built-in (`record`/`replay`) | ✅ Codegen | ❌ | ❌ |
|
|
921
978
|
| **Anti-Detection** | ✅ CDP firewall | ❌ | ❌ | ❌ |
|
|
922
|
-
| **AI Agent Integration** | ✅ Built-in plugins | Manual integration | Manual integration | Manual integration |
|
|
979
|
+
| **AI Agent Integration** | ✅ Built-in MCP server + plugins | Manual integration | Manual integration | Manual integration |
|
|
923
980
|
|
|
924
981
|
**When to use xbrowser:**
|
|
925
982
|
- You want to **automate browsers from the command line** without writing code
|
|
@@ -938,7 +995,7 @@ xbrowser/
|
|
|
938
995
|
|------|------|------|
|
|
939
996
|
| **@dyyz1993/xcli-core** | 通用 CLI 框架 | xbrowser 依赖的核心框架 |
|
|
940
997
|
| **@dyyz1993/xpage (mpage)** | 浏览器自动化引擎 | 独立项目,xbrowser **不依赖** mpage |
|
|
941
|
-
| **xbrowser** | 浏览器自动化 CLI |
|
|
998
|
+
| **xbrowser** | 浏览器自动化 CLI | 自包含,自带 CDP 驱动(不依赖 Playwright) |
|
|
942
999
|
|
|
943
1000
|
## 🔑 Keywords
|
|
944
1001
|
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
saveSessionDiskMeta,
|
|
22
22
|
setActivePage,
|
|
23
23
|
touchSession
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-PGEZJ6V3.js";
|
|
25
|
+
import "./chunk-ZCZELQCS.js";
|
|
26
26
|
import "./chunk-A7NEA4PA.js";
|
|
27
27
|
import "./chunk-SMYSNO4M.js";
|
|
28
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-IYCB2KJL.js";
|
|
29
29
|
import "./chunk-GDKLH7ZY.js";
|
|
30
30
|
import "./chunk-KFQGP6VL.js";
|
|
31
31
|
export {
|
|
@@ -21,9 +21,10 @@ import {
|
|
|
21
21
|
saveSessionDiskMeta,
|
|
22
22
|
setActivePage,
|
|
23
23
|
touchSession
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-KSB4PMCY.js";
|
|
25
|
+
import "./chunk-GYGVHWG3.js";
|
|
25
26
|
import "./chunk-SMYSNO4M.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-IYCB2KJL.js";
|
|
27
28
|
import "./chunk-GDKLH7ZY.js";
|
|
28
29
|
import "./chunk-KFQGP6VL.js";
|
|
29
30
|
export {
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
saveSessionDiskMeta,
|
|
22
22
|
setActivePage,
|
|
23
23
|
touchSession
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-ENTENDF5.js";
|
|
25
|
+
import "./chunk-6DS3T6UK.js";
|
|
26
26
|
import "./chunk-SMYSNO4M.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-IYCB2KJL.js";
|
|
28
28
|
import "./chunk-GDKLH7ZY.js";
|
|
29
29
|
import "./chunk-NEE6EMYA.js";
|
|
30
30
|
import "./chunk-6UJU2FJK.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CDPConnection,
|
|
3
|
+
CDPProtocolError,
|
|
4
|
+
XBBrowserImpl,
|
|
5
|
+
XBCDPSessionImpl,
|
|
6
|
+
XBContextImpl,
|
|
7
|
+
XBElementHandleImpl,
|
|
8
|
+
XBKeyboardImpl,
|
|
9
|
+
XBLocatorImpl,
|
|
10
|
+
XBMouseImpl,
|
|
11
|
+
XBPageImpl,
|
|
12
|
+
checkActionable,
|
|
13
|
+
launch,
|
|
14
|
+
scrollIntoView,
|
|
15
|
+
waitForActionable,
|
|
16
|
+
waitForNetworkIdle
|
|
17
|
+
} from "./chunk-GYGVHWG3.js";
|
|
18
|
+
import "./chunk-SMYSNO4M.js";
|
|
19
|
+
import {
|
|
20
|
+
connectToCDP,
|
|
21
|
+
findChrome,
|
|
22
|
+
getCDPTargets,
|
|
23
|
+
killChrome,
|
|
24
|
+
launchChrome
|
|
25
|
+
} from "./chunk-IYCB2KJL.js";
|
|
26
|
+
import "./chunk-GDKLH7ZY.js";
|
|
27
|
+
import "./chunk-KFQGP6VL.js";
|
|
28
|
+
export {
|
|
29
|
+
CDPConnection,
|
|
30
|
+
CDPProtocolError,
|
|
31
|
+
XBBrowserImpl,
|
|
32
|
+
XBCDPSessionImpl,
|
|
33
|
+
XBContextImpl,
|
|
34
|
+
XBElementHandleImpl,
|
|
35
|
+
XBKeyboardImpl,
|
|
36
|
+
XBLocatorImpl,
|
|
37
|
+
XBMouseImpl,
|
|
38
|
+
XBPageImpl,
|
|
39
|
+
checkActionable,
|
|
40
|
+
connectToCDP,
|
|
41
|
+
findChrome,
|
|
42
|
+
getCDPTargets,
|
|
43
|
+
killChrome,
|
|
44
|
+
launch,
|
|
45
|
+
launchChrome,
|
|
46
|
+
scrollIntoView,
|
|
47
|
+
waitForActionable,
|
|
48
|
+
waitForNetworkIdle
|
|
49
|
+
};
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
scrollIntoView,
|
|
15
15
|
waitForActionable,
|
|
16
16
|
waitForNetworkIdle
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZCZELQCS.js";
|
|
18
18
|
import "./chunk-A7NEA4PA.js";
|
|
19
19
|
import "./chunk-SMYSNO4M.js";
|
|
20
20
|
import {
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
getCDPTargets,
|
|
24
24
|
killChrome,
|
|
25
25
|
launchChrome
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-IYCB2KJL.js";
|
|
27
27
|
import "./chunk-GDKLH7ZY.js";
|
|
28
28
|
import "./chunk-KFQGP6VL.js";
|
|
29
29
|
export {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
scrollIntoView,
|
|
15
15
|
waitForActionable,
|
|
16
16
|
waitForNetworkIdle
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6DS3T6UK.js";
|
|
18
18
|
import "./chunk-SMYSNO4M.js";
|
|
19
19
|
import {
|
|
20
20
|
connectToCDP,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
getCDPTargets,
|
|
23
23
|
killChrome,
|
|
24
24
|
launchChrome
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-IYCB2KJL.js";
|
|
26
26
|
import "./chunk-GDKLH7ZY.js";
|
|
27
27
|
import "./chunk-6UJU2FJK.js";
|
|
28
28
|
import "./chunk-KFQGP6VL.js";
|