名称: spool
描述: "Threads CLI - 使用 OpenClaw 浏览器工具在 Meta 的 Threads 上阅读、发帖、回复和搜索。当用户想要与 Threads 互动时使用:发帖、阅读时间线、查看个人资料、回复帖子或搜索。"
主页: https://github.com/zizi-cat/spool
元数据: {"clawdhub":{"emoji":"🧵"}}
使用 OpenClaw 浏览器工具操作 Threads (threads.net)。
openclaw 浏览器配置文件需要 Xvfb 虚拟显示:
# 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"
# 提示用户手动登录
browser action=open profile=openclaw targetUrl="https://www.threads.net"
browser action=snapshot profile=openclaw compact=true
结果中可查看每个帖子的作者、内容、点赞/评论数。
步骤 1: 前往主页
browser action=open profile=openclaw targetUrl="https://www.threads.net"
browser action=snapshot profile=openclaw compact=true
步骤 2: 找到并点击 "What's new?" 按钮
在 snapshot 中查找包含 "What's new?" 或 "Empty text field" 的按钮的 ref
browser action=act profile=openclaw request={"kind":"click","ref":"e14"}
(ref 值每次 snapshot 都不同!务必从 snapshot 中确认)
步骤 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 也需从 snapshot 中确认)
步骤 5: 确认发布
browser action=snapshot profile=openclaw compact=true
→ 看到 "Posted" 文本和 "View" 链接即表示成功!
browser action=open profile=openclaw targetUrl="https://www.threads.net/@username"
browser action=snapshot profile=openclaw compact=true
browser action=open profile=openclaw targetUrl="https://www.threads.net/search?q=搜索词"
browser action=snapshot profile=openclaw compact=true
# 打开帖子
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>"}
# 输入文本并发布(与发帖流程相同)
| 问题 | 解决方案 |
|---|---|
| 浏览器工具不工作 | 检查 Xvfb 是否运行,确认 DISPLAY=:99 设置,重启 Gateway |
| 无法登录 | 导航到 /login 页面,然后提示用户手动登录 |
| 找不到 ref | 重新 snapshot,查找相似的文本/按钮 |
| 无法发布 | 检查 Post 按钮是否处于禁用状态(可能需要输入文本) |