介绍
# spool
使用 OpenClaw 浏览器工具操作 Threads (threads.net)。
## 前置要求
### 环境要求 - 已启用浏览器工具的 OpenClaw - `openclaw` 浏览器配置文件 - 已完成 Threads 账号登录
### 如果是无头服务器(无 GUI)
需要 Xvfb 虚拟显示:
```bash # 1. Xvfb 설치 및 서비스 등록 sudo apt install -y xvfb sudo tee /etc/systemd/system/xvfb.service << 'EOF' [Unit] Description=X Virtual Frame Buffer After=network.target [Service] Type=simple ExecStart=/usr/bin/Xvfb :99 -screen 0 1920x1080x24 Restart=always [Install] WantedBy=multi-user.target EOF sudo systemctl enable --now xvfb
# 2. OpenClaw Gateway에 DISPLAY 환경변수 추가 mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d echo -e '[Service]\nEnvironment=DISPLAY=:99' > ~/.config/systemd/user/openclaw-gateway.service.d/display.conf systemctl --user daemon-reload systemctl --user restart openclaw-gateway ```
### 登录(仅需一次)
``` browser action=start profile=openclaw browser action=open profile=openclaw targetUrl="https://www.threads.net/login" # 사용자에게 수동 로그인 요청 ```
---
## 用法
### 1. 读取时间线
``` browser action=open profile=openclaw targetUrl="https://www.threads.net" browser action=snapshot profile=openclaw compact=true ```
结果中可查看每个帖子的作者、内容、点赞/评论数。
### 2. 发布帖子(完整流程)
**步骤 1:前往首页** ``` browser action=open profile=openclaw targetUrl="https://www.threads.net" browser action=snapshot profile=openclaw compact=true ```
**步骤 2:查找并点击“What's new?”按钮** 在快照中查找包含 `"What's new?"` 或 `"Empty text field"` 的 button 的 ref ``` browser action=act profile=openclaw request={"kind":"click","ref":"e14"} ``` (ref 在每个快照中都不同!务必在快照中确认)
**步骤 3:在对话框中输入文本** ``` browser action=snapshot profile=openclaw compact=true ``` 找到 `textbox` 的 ref: ``` browser action=act profile=openclaw request={"kind":"type","ref":"e14","text":"포스팅 내용"} ```
**步骤 4:点击 Post 按钮** ``` browser action=act profile=openclaw request={"kind":"click","ref":"e22"} ``` (Post 按钮的 ref 也需在快照中确认)
**步骤 5:确认** ``` browser action=snapshot profile=openclaw compact=true ``` → 如果看到 "Posted" 文本和 "View" 链接,即表示成功!
### 3. 查看个人资料
``` browser action=open profile=openclaw targetUrl="https://www.threads.net/@username" browser action=snapshot profile=openclaw compact=true ```
### 4. 搜索
``` browser action=open profile=openclaw targetUrl="https://www.threads.net/search?q=검색어" browser action=snapshot profile=openclaw compact=true ```
### 5. 回复
``` # 게시물 열기 browser action=open profile=openclaw targetUrl="https://www.threads.net/@user/post/POSTID" browser action=snapshot profile=openclaw compact=true
# Reply 버튼 클릭 (ref 확인 후) browser action=act profile=openclaw request={"kind":"click","ref":"<reply-ref>"}
# 텍스트 입력 및 게시 (포스팅과 동일) ```
---
## 关键点
1. **先看快照!** - 在所有操作前,先通过快照确认当前页面状态和 ref 2. **ref 每次都不同** - 始终从快照结果中重新查找 3. **compact=true** - 为节省 token 务必使用 4. **保持 targetId** - 若要在同一标签页操作,需使用 targetId 参数 5. **发布前确认** - 让用户确认内容后再发布
---
## 故障排查
| 问题 | 解决方法 | |------|------| | 浏览器工具不可用 | 检查 Xvfb 是否运行,检查 DISPLAY=:99 设置,重启 Gateway | | 无法登录 | 导航至 `/login` 页面后请求手动登录 | | 找不到 ref | 重新截图(snapshot)并查找相似的文本/按钮 | | 无法发布 | 检查 Post 按钮是否被禁用(需要输入文本) |