docs: update user-facing docs with real test results from baidu.com verification
This commit is contained in:
+96
-47
@@ -1,89 +1,138 @@
|
||||
# VisionL 快速开始
|
||||
|
||||
## 环境要求
|
||||
|
||||
- Node.js >= 18
|
||||
- Chromium 浏览器(系统自带或 Playwright 安装)
|
||||
- Linux/macOS/Windows(Android 需配合 Ubuntu proot 容器)
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
# 1. 克隆仓库
|
||||
git clone ssh://git@git.yeij.top:2222/AskaEth/VisionL.git
|
||||
cd VisionL
|
||||
|
||||
# 2. 安装依赖
|
||||
npm install
|
||||
|
||||
# 3. 安装 Chromium 浏览器
|
||||
npx playwright install chromium
|
||||
|
||||
# 4. 构建
|
||||
npm install --registry=https://registry.npmmirror.com
|
||||
npx playwright install chromium # 如果没有系统 Chromium
|
||||
npm run build
|
||||
```
|
||||
|
||||
# 5. 全局安装 CLI(可选)
|
||||
cd packages/cli && npm link
|
||||
## 启动
|
||||
|
||||
```bash
|
||||
# 方式一:使用内置启动脚本
|
||||
node start-daemon.js &
|
||||
|
||||
# 方式二:直接运行 daemon
|
||||
VISIONL_PORT=9527 node packages/daemon/dist/server.js &
|
||||
```
|
||||
|
||||
## 基本使用
|
||||
|
||||
### 启动 daemon
|
||||
所有命令输出 JSON 格式,可使用 `--pretty` 切换为人类可读。
|
||||
|
||||
### 打开页面
|
||||
|
||||
```bash
|
||||
visionl daemon start
|
||||
# ✓ Daemon 已启动 (端口 9527, PID 12345)
|
||||
curl -X POST http://127.0.0.1:9527/pages \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"url":"https://www.baidu.com","alias":"baidu"}'
|
||||
```
|
||||
|
||||
### 打开一个页面
|
||||
|
||||
```bash
|
||||
visionl page open https://www.baidu.com --alias baidu
|
||||
# {"ok":true,"data":{"id":"p_a1b2c3d4","url":"https://www.baidu.com","alias":"baidu","title":"百度一下,你就知道","status":"active"}}
|
||||
返回:
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"data": {
|
||||
"id": "p_f1990959",
|
||||
"url": "https://www.baidu.com",
|
||||
"alias": "baidu",
|
||||
"title": "百度一下,你就知道",
|
||||
"status": "active",
|
||||
"profile": "desktop-chrome"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 获取页面文本
|
||||
|
||||
```bash
|
||||
visionl text baidu
|
||||
# {"ok":true,"data":{"text":"百度一下,你就知道\n..."}}
|
||||
curl http://127.0.0.1:9527/pages/baidu/text
|
||||
```
|
||||
|
||||
### 搜索
|
||||
|
||||
```bash
|
||||
visionl type baidu "#kw" "VisionL"
|
||||
visionl click baidu "#su"
|
||||
# 输入搜索词
|
||||
curl -X POST http://127.0.0.1:9527/pages/baidu/type \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"selector":"#kw","text":"VisionL"}'
|
||||
|
||||
# 点击搜索按钮
|
||||
curl -X POST http://127.0.0.1:9527/pages/baidu/click \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"selector":"#su"}'
|
||||
|
||||
# 等待结果加载
|
||||
curl -X POST http://127.0.0.1:9527/pages/baidu/wait \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"ms":2000}'
|
||||
|
||||
# 获取搜索结果
|
||||
curl http://127.0.0.1:9527/pages/baidu/text
|
||||
```
|
||||
|
||||
### 截图
|
||||
|
||||
```bash
|
||||
visionl screenshot baidu -o result.png
|
||||
curl http://127.0.0.1:9527/pages/baidu/screenshot
|
||||
# 返回 base64 编码的 PNG 图片
|
||||
```
|
||||
|
||||
### 执行 JavaScript
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:9527/pages/baidu/eval \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"code":"document.title"}'
|
||||
# {"ok":true,"data":{"result":"百度一下,你就知道"}}
|
||||
```
|
||||
|
||||
### Cookie 管理
|
||||
|
||||
```bash
|
||||
# 查看所有 Cookie
|
||||
curl http://127.0.0.1:9527/pages/baidu/cookies
|
||||
|
||||
# 设置 Cookie
|
||||
curl -X POST http://127.0.0.1:9527/pages/baidu/cookies \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"name":"mycookie","value":"hello","domain":".baidu.com"}'
|
||||
```
|
||||
|
||||
### 网络请求监控
|
||||
|
||||
```bash
|
||||
# 查看网络请求日志
|
||||
curl http://127.0.0.1:9527/pages/baidu/network
|
||||
```
|
||||
|
||||
### 查看指纹配置
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:9527/profiles
|
||||
# [{"id":"desktop-chrome","name":"桌面 Chrome (通用)"},
|
||||
# {"id":"desktop-windows","name":"桌面 Chrome (Windows)"},
|
||||
# {"id":"desktop-mac","name":"桌面 Chrome (macOS)"}]
|
||||
```
|
||||
|
||||
### 关闭页面
|
||||
|
||||
```bash
|
||||
visionl page kill baidu
|
||||
# {"ok":true,"data":null}
|
||||
curl -X DELETE http://127.0.0.1:9527/pages/baidu
|
||||
```
|
||||
|
||||
### 停止 daemon
|
||||
### 查看所有页面
|
||||
|
||||
```bash
|
||||
visionl daemon stop
|
||||
```
|
||||
|
||||
## 无需手动启动 daemon
|
||||
|
||||
CLI 会自动检测 daemon 是否运行,未运行则自动启动:
|
||||
|
||||
```bash
|
||||
# 直接使用,CLI 自动拉起 daemon
|
||||
visionl page open https://example.com
|
||||
|
||||
# 关闭所有页面(daemon 继续运行)
|
||||
visionl page kill-all
|
||||
```
|
||||
|
||||
## 查看所有页面
|
||||
|
||||
```bash
|
||||
visionl page list
|
||||
# {"ok":true,"data":[{"id":"p_xxx","url":"...","alias":"...","title":"...","status":"active"}]}
|
||||
curl http://127.0.0.1:9527/pages
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user