Automate posting to Jike (即刻) 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 Jike homepage
browser(action="navigate", targetUrl="https://web.okjike.com/following", targetId=<tab_id>)
# 3. Get page snapshot to find elements
browser(action="snapshot", targetId=<tab_id>)
# 4. Click the post textbox (ref from snapshot)
# Look for: textarea or contenteditable div
browser(action="act", request={"kind": "click", "ref": "<textbox_ref>"}, targetId=<tab_id>)
# 5. Type content with Unicode escape
browser(action="act", request={"kind": "type", "ref": "<textbox_ref>", "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 "发布" text)
browser(action="act", request={"kind": "click", "ref": "<send_ref>"}, targetId=<tab_id>)
# 8. Wait and verify
sleep(3)
browser(action="snapshot", targetId=<tab_id>)
即刻的页面元素引用需要通过 snapshot 实际获取,常见元素:
重要: 元素引用会频繁变化,每次操作前都要先 snapshot!
记录发布历史到 memory/jike-state.json:
{
"lastPublishTime": 1740880260,
"lastPublishDate": "2026-03-16T12:38:00+08:00",
"lastContent": "Your last post content..."
}
// ✅ 正确
request={"kind": "type", "ref": "eXXX", "text": "content"}
// ❌ 错误
request="{\"kind\": \"type\", \"ref\": \"eXXX\", \"text\": \"content\"}"
问题: 中文引号(""、'')会导致 JSON 解析错误
解决: 使用 Unicode 转义:
# 转换中文为 Unicode 转义
text = "刚刚看到一篇很棒的技术文章"
escaped = text.encode('unicode_escape').decode('ascii')
# 结果: \u521a\u521a\u770b\u5230\u4e00\u7bc87\u5f88\u68d2\u7684\u6280\u672f\u6587\u7ae0
共 1 个版本