Weibo Publisher
Publish content to Weibo through browser automation on m.weibo.cn (mobile web version).
Prerequisites
- - Browser must be running with valid Weibo login session
- Images must be placed in
/tmp/openclaw/uploads/ before upload - Requires manual verification after posting (compose page doesn't auto-redirect)
Publishing Workflow
1. Open Compose Page
CODEBLOCK0
2. Input Text Content
Get snapshot to find textbox ref, then type content:
CODEBLOCK1
3. Upload Images (Optional)
Important: Images must be in /tmp/openclaw/uploads/ directory.
CODEBLOCK2
Upload using the upload button ref (not the hidden file input):
CODEBLOCK3
Verification: Wait 2-3 seconds, then screenshot to confirm image preview is visible on page.
4. Publish Post
Click the send button:
CODEBLOCK4
5. Verify Publication (Critical)
Do NOT rely on page redirect - compose page stays open.
Verification steps:
- 1. Wait 5 seconds for backend processing
- Navigate to personal page:
browser open https://m.weibo.cn
browser act kind=click ref=<profile-avatar-ref> // Top-left avatar
- 3. Check latest post matches what was just published
- Close compose page to prevent accidental repost:
CODEBLOCK6
6. Cleanup (Required)
After successful publication, clean up temporary files:
CODEBLOCK7
Note: Temporary files are NOT automatically cleaned up. Cleanup is required - always run it after publishing.
Page Element References
Common refs on m.weibo.cn/compose:
- - Text input:
ref=e15 (textbox "分享新鲜事…") - Send button:
ref=e10 ("发送") - Image upload button:
ref=e25 or ref=e29 ( icon)
Note: Refs are dynamic - always get fresh snapshot before interacting.
Error Handling
| Issue | Solution |
|---|
| Image upload shows "图片选择失败" | File not in /tmp/openclaw/uploads/. Move file to correct location. |
| Send button not responding |
Check if textbox is empty. Weibo requires at least text or image. |
| Post not appearing after 5s | Wait longer (network delay) or check login status. |
Anti-Duplication Measures
- - Always verify post exists on personal page before considering task complete
- Always close compose tab after successful verification
- If uncertain whether post succeeded, check personal page before retrying
References
See references/workflow-examples.md for complete code examples.
微博发布器
通过浏览器自动化在 m.weibo.cn(移动网页版)上发布内容到微博。
前置条件
- - 浏览器必须已登录有效的微博账号
- 图片在上传前需放置在 /tmp/openclaw/uploads/ 目录下
- 发布后需要手动验证(编辑页面不会自动跳转)
发布流程
1. 打开编辑页面
browser open https://m.weibo.cn/compose
2. 输入文本内容
获取页面快照找到文本框引用,然后输入内容:
javascript
// 示例:发布文本
browser act kind=type ref=<文本框引用> text=你的微博内容
3. 上传图片(可选)
重要: 图片必须位于 /tmp/openclaw/uploads/ 目录下。
bash
准备图片(示例)
cp /path/to/image.png /tmp/openclaw/uploads/
使用上传按钮引用(而非隐藏的文件输入)进行上传:
javascript
// 上传图片 - 使用上传按钮引用
browser upload inputRef=<上传按钮引用> paths=[/tmp/openclaw/uploads/image.png]
// 等待 2-3 秒让上传完成
// 截图确认预览已显示
验证: 等待 2-3 秒后截图,确认页面上能看到图片预览。
4. 发布微博
点击发送按钮:
javascript
browser act kind=click ref=<发送按钮引用>
5. 验证发布(关键步骤)
不要依赖页面跳转——编辑页面会保持打开状态。
验证步骤:
- 1. 等待 5 秒让后端处理
- 导航到个人页面:
browser open https://m.weibo.cn
browser act kind=click ref=<个人头像引用> // 左上角头像
- 3. 检查最新微博是否与刚发布的内容一致
- 关闭编辑页面以防止意外重复发布:
browser action=close targetId=<编辑标签页ID>
6. 清理(必需)
成功发布后,清理临时文件:
bash
从临时目录删除已上传的图片
rm /tmp/openclaw/uploads/<文件名>
可选:清理 7 天前的浏览器截图
find ~/.openclaw/media/browser/ -type f -mtime +7 -delete
注意: 临时文件不会自动清理。清理是必需的——发布后务必执行。
页面元素引用
m.weibo.cn/compose 上的常见引用:
- - 文本输入框:ref=e15(文本框 分享新鲜事…)
- 发送按钮:ref=e10(发送)
- 图片上传按钮:ref=e25 或 ref=e29( 图标)
注意: 引用是动态的——交互前务必获取最新的页面快照。
错误处理
| 问题 | 解决方案 |
|---|
| 图片上传显示图片选择失败 | 文件不在 /tmp/openclaw/uploads/ 目录中。将文件移动到正确位置。 |
| 发送按钮无响应 |
检查文本框是否为空。微博至少需要文本或图片。 |
| 5 秒后微博未显示 | 等待更长时间(网络延迟)或检查登录状态。 |
防重复措施
- - 在认为任务完成前,务必验证微博已出现在个人页面
- 验证成功后务必关闭编辑标签页
- 如果不确定微博是否发布成功,先检查个人页面再重试
参考
完整代码示例请参见 references/workflow-examples.md