Files

139 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# VisionL 快速开始
## 环境要求
- Node.js >= 18
- Chromium 浏览器(系统自带或 Playwright 安装)
- Linux/macOS/WindowsAndroid 需配合 Ubuntu proot 容器)
## 安装
```bash
git clone ssh://git@git.yeij.top:2222/AskaEth/VisionL.git
cd VisionL
npm install --registry=https://registry.npmmirror.com
npx playwright install chromium # 如果没有系统 Chromium
npm run build
```
## 启动
```bash
# 方式一:使用内置启动脚本
node start-daemon.js &
# 方式二:直接运行 daemon
VISIONL_PORT=9527 node packages/daemon/dist/server.js &
```
## 基本使用
所有命令输出 JSON 格式,可使用 `--pretty` 切换为人类可读。
### 打开页面
```bash
curl -X POST http://127.0.0.1:9527/pages \
-H 'Content-Type: application/json' \
-d '{"url":"https://www.baidu.com","alias":"baidu"}'
```
返回:
```json
{
"ok": true,
"data": {
"id": "p_f1990959",
"url": "https://www.baidu.com",
"alias": "baidu",
"title": "百度一下,你就知道",
"status": "active",
"profile": "desktop-chrome"
}
}
```
### 获取页面文本
```bash
curl http://127.0.0.1:9527/pages/baidu/text
```
### 搜索
```bash
# 输入搜索词
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
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
curl -X DELETE http://127.0.0.1:9527/pages/baidu
```
### 查看所有页面
```bash
curl http://127.0.0.1:9527/pages
```