Automate posting to Weibo (Sina Weibo) using browser automation through OpenClaw's managed browser.
# 1. Prepare content with Unicode escape (for Chinese text)
content = "刚刚解决了一个技术难题!💪"
escaped_content = content.encode('unicode_escape').decode('ascii')
# 2. Navigate to Weibo homepage
browser(action="navigate", targetUrl="https://weibo.com/", targetId=<tab_id>)
# 3. Get page snapshot to find elements
browser(action="snapshot", targetId=<tab_id>)
# 4. Click the post textbox (ref from snapshot, usually e31 or e136)
browser(action="act", request={"kind": "click", "ref": "e31"}, targetId=<tab_id>)
# 5. Type content with Unicode escape
browser(action="act", request={"kind": "type", "ref": "e31", "text": escaped_content}, targetId=<tab_id>)
# 6. Get fresh snapshot to find send button
browser(action="snapshot", targetId=<tab_id>)
# 7. Click send button (ref from snapshot, usually e32 or e194)
browser(action="act", request={"kind": "click", "ref": "e32"}, targetId=<tab_id>)
# 8. Wait and verify by navigating to profile
sleep(3)
browser(action="navigate", targetUrl="https://weibo.com/u/<your_uid>", targetId=<tab_id>)
browser(action="snapshot", targetId=<tab_id>)
Common element references on Weibo homepage (as of 2026-03-02):
e31 (placeholder: "有什么新鲜事想分享给大家?")e32 (text: "发送", becomes enabled after typing)e10 (text: "发微博")e746 (when using quick post popup)e804Important Notes:
/) and profile page (/u/)#topic# format (e.g., "#微博话题#")@username format\n in textUse the main homepage textbox for quick posts:
https://weibo.com/Use the "发微博" button for popup posting:
https://weibo.com/For posts to be published later:
Track posting history in memory/weibo-state.json:
{
"lastPublishTime": 1740880260,
"lastPublishDate": "2026-03-02T12:38:00+08:00",
"lastContent": "Your last post content..."
}
Update this file after each successful post.
Validation failed for tool "browser": - request: must be objectdisabled attribute\ud83d\udcaa for 💪)openclaw (managed browser)Critical: The request parameter must be a JSON object, not a string:
// ✅ Correct
request={"kind": "type", "ref": "e136", "text": "content"}
// ❌ Wrong
request="{\"kind\": \"type\", \"ref\": \"e136\", \"text\": \"content\"}"
Problem: Chinese quotation marks (""、'') in JSON text can cause parsing errors.
Solution: Use Unicode escape (\uXXXX) for all Chinese characters:
# Convert Chinese text to Unicode escape
text = "刚刚解决了一个技术难题,感觉特别有成就感!"
escaped = text.encode('unicode_escape').decode('ascii')
# Result: \u521a\u521a\u89e3\u51b3\u4e86...
Example:
// ✅ Correct - Unicode escaped
request={"kind": "type", "ref": "e31", "text": "\u521a\u521a\u89e3\u51b3\u4e86\u4e00\u4e2a\u6280\u672f\u96be\u9898"}
// ❌ Wrong - Direct Chinese with quotes
request={"kind": "type", "ref": "e31", "text": "刚刚解决了一个"技术难题""}
Why: Chinese quotation marks conflict with JSON string delimiters, causing the request parameter to be serialized as a string instead of an object.
共 1 个版本