WeChat MP Smart Publish — 公众号自动发布 将 Markdown 文章一键发布到微信公众号草稿箱。 什么时候用 - 有了写好的公众号文章(markdown),需要上传到草稿箱 - 批量发布内容到微信公众号 - 自动化内容分发 pipeline 中的一环 - 其他 agent(小content等)需要发布公众号内容时 不适用 - ❌ 需要直接正式发布(不是草稿)— 当前仅支持存草稿,由人工最终发布 - ❌ 视频内容 — 仅支持图文消息 - ❌ 需要编辑已发布文章 前置条件 | 条件 | 说明 | 检查方法 | |------|------|---------| | Playwright | Python playwright 库 | | | OpenClaw Browser | 浏览器服务运行中 | 或检查 | | 微信 Cookie | Playwright state 文件有效 | | | Cookie 未过期 | cookies 包含 qname 和 uin | 检查 cookie 中 qname 字段 | 输入 Markdown 格式要求 输出 使用方法 方式一:直接运行脚本 方式二:作为模块调用 方式三:Agent 调用(推荐) 其他 agent 通过 sessions send 请小code 执行: 核心流程 排版规范 | 参数 | 值 | |-…

, '\\\\

WeChat MP Smart Publish — 公众号自动发布 将 Markdown 文章一键发布到微信公众号草稿箱。 什么时候用 - 有了写好的公众号文章(markdown),需要上传到草稿箱 - 批量发布内容到微信公众号 - 自动化内容分发 pipeline 中的一环 - 其他 agent(小content等)需要发布公众号内容时 不适用 - ❌ 需要直接正式发布(不是草稿)— 当前仅支持存草稿,由人工最终发布 - ❌ 视频内容 — 仅支持图文消息 - ❌ 需要编辑已发布文章 前置条件 | 条件 | 说明 | 检查方法 | |------|------|---------| | Playwright | Python playwright 库 | | | OpenClaw Browser | 浏览器服务运行中 | 或检查 | | 微信 Cookie | Playwright state 文件有效 | | | Cookie 未过期 | cookies 包含 qname 和 uin | 检查 cookie 中 qname 字段 | 输入 Markdown 格式要求 输出 使用方法 方式一:直接运行脚本 方式二:作为模块调用 方式三:Agent 调用(推荐) 其他 agent 通过 sessions send 请小code 执行: 核心流程 排版规范 | 参数 | 值 | |-…

)}`);\n }}\n }}\n ''')\n break\n except Exception:\n continue\n \n # Fallback: try page-level content injection\n await page.evaluate(f'''\n () => {{\n // Try multiple UEditor instances\n const editors = document.querySelectorAll('iframe');\n for (const frame of editors) {{\n try {{\n const doc = frame.contentDocument || frame.contentWindow.document;\n if (doc && doc.querySelector('body')) {{\n doc.body.innerHTML = `{body_html.replace('`', '\\\\`').replace('

WeChat MP Smart Publish — 公众号自动发布 将 Markdown 文章一键发布到微信公众号草稿箱。 什么时候用 - 有了写好的公众号文章(markdown),需要上传到草稿箱 - 批量发布内容到微信公众号 - 自动化内容分发 pipeline 中的一环 - 其他 agent(小content等)需要发布公众号内容时 不适用 - ❌ 需要直接正式发布(不是草稿)— 当前仅支持存草稿,由人工最终发布 - ❌ 视频内容 — 仅支持图文消息 - ❌ 需要编辑已发布文章 前置条件 | 条件 | 说明 | 检查方法 | |------|------|---------| | Playwright | Python playwright 库 | | | OpenClaw Browser | 浏览器服务运行中 | 或检查 | | 微信 Cookie | Playwright state 文件有效 | | | Cookie 未过期 | cookies 包含 qname 和 uin | 检查 cookie 中 qname 字段 | 输入 Markdown 格式要求 输出 使用方法 方式一:直接运行脚本 方式二:作为模块调用 方式三:Agent 调用(推荐) 其他 agent 通过 sessions send 请小code 执行: 核心流程 排版规范 | 参数 | 值 | |-…

, '\\\\

WeChat MP Smart Publish — 公众号自动发布 将 Markdown 文章一键发布到微信公众号草稿箱。 什么时候用 - 有了写好的公众号文章(markdown),需要上传到草稿箱 - 批量发布内容到微信公众号 - 自动化内容分发 pipeline 中的一环 - 其他 agent(小content等)需要发布公众号内容时 不适用 - ❌ 需要直接正式发布(不是草稿)— 当前仅支持存草稿,由人工最终发布 - ❌ 视频内容 — 仅支持图文消息 - ❌ 需要编辑已发布文章 前置条件 | 条件 | 说明 | 检查方法 | |------|------|---------| | Playwright | Python playwright 库 | | | OpenClaw Browser | 浏览器服务运行中 | 或检查 | | 微信 Cookie | Playwright state 文件有效 | | | Cookie 未过期 | cookies 包含 qname 和 uin | 检查 cookie 中 qname 字段 | 输入 Markdown 格式要求 输出 使用方法 方式一:直接运行脚本 方式二:作为模块调用 方式三:Agent 调用(推荐) 其他 agent 通过 sessions send 请小code 执行: 核心流程 排版规范 | 参数 | 值 | |-…

)}`;\n doc.body.dispatchEvent(new Event('input', {{ bubbles: true }}));\n }}\n }} catch(e) {{ /* cross-origin, skip */ }}\n }}\n }}\n ''')\n \n await page.wait_for_timeout(2000)\n \n # Take screenshot before saving\n await page.screenshot(path=screenshot_path)\n print(f\"📸 Screenshot saved: {screenshot_path}\")\n \n # Save as draft\n if decision == \"draft\":\n print('💾 Saving as draft...')\n try:\n await click_by_text(page, \"保存\")\n await page.wait_for_timeout(3000)\n print(\"✅ Draft saved!\")\n except Exception as e:\n print(f\"⚠️ Save failed: {e}\")\n # Try alternative save button\n try:\n save_btn = page.locator('button:has-text(\"保存\")').first\n await save_btn.click()\n await page.wait_for_timeout(3000)\n except Exception:\n pass\n \n # Final screenshot\n await page.screenshot(path=screenshot_path)\n \n return {\n \"status\": \"ok\",\n \"draft_saved\": decision == \"draft\",\n \"screenshot_path\": screenshot_path,\n \"title\": title,\n \"title_truncated\": len(article.get(\"title\", \"\")) > TITLE_MAX,\n \"content_length\": len(body_html),\n }\n \n except Exception as e:\n await page.screenshot(path=screenshot_path)\n return {\n \"status\": \"error\",\n \"error\": str(e),\n \"screenshot_path\": screenshot_path,\n }\n \n finally:\n await page.close()\n await context.close()\n await browser.disconnect()\n\n\n# ─── CLI Entry Point ────────────────────────────────────────────────\ndef main():\n parser = argparse.ArgumentParser(description=\"WeChat MP Smart Publish\")\n parser.add_argument(\"--article\", required=True, help=\"Markdown article path\")\n parser.add_argument(\"--cover\", required=True, help=\"Cover image path (jpg/png)\")\n parser.add_argument(\"--decision\", default=\"draft\", choices=[\"draft\", \"publish\"],\n help=\"Publish decision (default: draft)\")\n \n args = parser.parse_args()\n \n print(f\"\"\"\n╔══════════════════════════════════════════════╗\n║ WeChat MP Smart Publish v1.0.0 ║\n╠══════════════════════════════════════════════╣\n║ Article : {args.article}\n║ Cover : {args.cover}\n║ Decision: {args.decision}\n╚══════════════════════════════════════════════╝\n \"\"\")\n \n result = asyncio.run(publish_to_wechat(\n article_path=args.article,\n cover_path=args.cover,\n decision=args.decision,\n ))\n \n print(\"\\n📊 Result:\")\n print(json.dumps(result, indent=2, ensure_ascii=False))\n \n sys.exit(0 if result.get(\"status\") == \"ok\" else 1)\n\n\nif __name__ == \"__main__\":\n main()\n","content_type":"text/x-python; charset=utf-8","language":"python","size":16329,"content_sha256":"596d7940eb861990ba74eb6a70366dae3735a0bc51d003e2d13a02e6b4776616"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"WeChat MP Smart Publish — 公众号自动发布","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"将 Markdown 文章一键发布到微信公众号草稿箱。","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"什么时候用","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有了写好的公众号文章(markdown),需要上传到草稿箱","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"批量发布内容到微信公众号","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"自动化内容分发 pipeline 中的一环","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"其他 agent(小content等)需要发布公众号内容时","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"不适用","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"❌ 需要直接正式发布(不是草稿)— 当前仅支持存草稿,由人工最终发布","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"❌ 视频内容 — 仅支持图文消息","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"❌ 需要编辑已发布文章","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"前置条件","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"条件","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"说明","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"检查方法","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Playwright","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Python playwright 库","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"pip show playwright","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"OpenClaw Browser","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"浏览器服务运行中","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"openclaw browser status","type":"text","marks":[{"type":"code_inline"}]},{"text":" 或检查 ","type":"text"},{"text":"127.0.0.1:18800","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"微信 Cookie","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Playwright state 文件有效","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"cat ~/.playwright-data/wechat/state-default.json | python3 -c \"import json,sys; d=json.load(sys.stdin); print(f'Cookies: {len(d.get(\\\"cookies\\\",[]))}')\"","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Cookie 未过期","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"cookies 包含 qname 和 uin","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"检查 cookie 中 qname 字段","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"输入","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"yaml"},"content":[{"text":"输入参数:\n article_path: string # Markdown 文件路径\n cover_path: string # 封面图路径 (jpg/png, 推荐 2.35:1 比例, ≥900x383)\n decision: draft # 当前仅支持 draft","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Markdown 格式要求","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"markdown"},"content":[{"text":"# 标题(文章标题,≤64字)\n\n正文内容,支持 **加粗**、*斜体*、`行内代码` 等常见 Markdown 语法。\n\n## 子标题\n\n段落文字...","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"输出","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"yaml"},"content":[{"text":"输出:\n status: ok | error\n draft_saved: true/false\n draft_url: string # 草稿箱URL\n screenshot_path: string # 截图路径\n title: string # 实际使用的标题\n content_length: number # 正文字数","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"使用方法","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"方式一:直接运行脚本","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python3 ~/clawd/skills/wechat-mp-smart-publish/scripts/publish.py \\\n --article /path/to/article.md \\\n --cover /path/to/cover.jpg \\\n --decision draft","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"方式二:作为模块调用","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"python"},"content":[{"text":"import asyncio\nfrom scripts.publish import publish_to_wechat\n\nresult = asyncio.run(publish_to_wechat(\n article_path=\"/path/to/article.md\",\n cover_path=\"/path/to/cover.jpg\",\n decision=\"draft\",\n))\nprint(result)","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"方式三:Agent 调用(推荐)","type":"text"}]},{"type":"paragraph","content":[{"text":"其他 agent 通过 sessions_send 请小code 执行:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"请发布文章到微信公众号草稿箱:\n- 文章: ~/clawd/docs/daily-content/2026-04-14/gzh/amd-gaia-article.md\n- 封面: ~/clawd/docs/daily-content/2026-04-14/gzh/cover.jpg","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"核心流程","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"解析 Markdown → Markdown→HTML 转换 → 启动浏览器 → 加载 Cookie\n→ 打开公众号首页 → 点击\"新的创作\" → 上传封面图\n→ 填充标题 → 切换到图文消息 → 粘贴正文HTML\n→ 截图 → 存草稿","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"排版规范","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"参数","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"值","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"正文字号","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"15px","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"正文字色","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"#3f3f3f","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"行高","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"1.75 倍","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"段落间距","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"1em","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"标题字号","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"H2: 18px bold, H3: 16px bold","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"代码块","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"背景 #f6f8fa,左边框 3px solid #fe6","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"关键 Selector(2026-04-14 验证)","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"元素","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"CSS Selector","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"说明","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"首页入口","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"\"新的创作\" (button/tab text)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"新建图文","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"封面图上传","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"input[type=\"file\"]","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"图片上传 input","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"标题输入","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"input[name=\"title\"]","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"文章标题","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"图文切换","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"\"图文\" (tab text)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"切换到富文本编辑器","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"富文本编辑器","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"#ueditor_0","type":"text","marks":[{"type":"code_inline"}]},{"text":" iframe 或 ","type":"text"},{"text":".edit_area","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"UEditor iframe","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"预览按钮","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"\"预览\" (button text)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"预览草稿","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"存草稿按钮","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"\"保存\" (button text)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"存为草稿","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"边界处理","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"1. 标题 64 字限制","type":"text"}]},{"type":"paragraph","content":[{"text":"标题超出 64 字时自动截断。","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"2. Markdown→HTML 转换","type":"text"}]},{"type":"paragraph","content":[{"text":"使用基础转换规则:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"# H1","type":"text","marks":[{"type":"code_inline"}]},{"text":" → ","type":"text"},{"text":"\u003ch1>","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"**bold**","type":"text","marks":[{"type":"code_inline"}]},{"text":" → ","type":"text"},{"text":"\u003cstrong>bold\u003c/strong>","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"*italic*","type":"text","marks":[{"type":"code_inline"}]},{"text":" → ","type":"text"},{"text":"\u003cem>italic\u003c/em>","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"`code`","type":"text","marks":[{"type":"code_inline"}]},{"text":" → ","type":"text"},{"text":"\u003ccode>code\u003c/code>","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"空行 → ","type":"text"},{"text":"\u003cbr>","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"---","type":"text","marks":[{"type":"code_inline"}]},{"text":" → ","type":"text"},{"text":"\u003chr>","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"3. UEditor 特殊填充","type":"text"}]},{"type":"paragraph","content":[{"text":"UEditor 是富文本 iframe,不能直接操作内容。需通过:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"python"},"content":[{"text":"# 切换到编辑模式\nawait page.evaluate('''() => {\n const editor = document.querySelector('#ueditor_0');\n if (editor && editor.contentWindow) {\n editor.contentWindow.postMessage({type: 'setContent', content: html}, '*');\n }\n}''')","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"4. 封面图比例","type":"text"}]},{"type":"paragraph","content":[{"text":"微信封面图推荐比例 2.35:1,最小尺寸 900x383。","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"5. Cookie 管理","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Cookie 文件位置:","type":"text"},{"text":"~/.playwright-data/wechat/state-default.json","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有效期约 7-30 天,需要定期通过浏览器登录续期","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"加载方式:","type":"text"},{"text":"await context.add_cookies(cookies_from_state)","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"检查登录:页面出现\"新的创作\"按钮即为已登录","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"常见问题","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Q: 页面找不到\"新的创作\"按钮?","type":"text"}]},{"type":"paragraph","content":[{"text":"A: Cookie 过期,需重新扫码登录。执行:","type":"text"},{"text":"openclaw browser open --url https://mp.weixin.qq.com","type":"text","marks":[{"type":"code_inline"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Q: 富文本编辑器无法填充内容?","type":"text"}]},{"type":"paragraph","content":[{"text":"A: UEditor 需要切换到编辑模式。先点击编辑器区域激活,再执行 JS 注入。","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Q: 浏览器连接失败?","type":"text"}]},{"type":"paragraph","content":[{"text":"A: 检查 OpenClaw browser 是否运行:","type":"text"},{"text":"curl -s http://127.0.0.1:18800/json/version","type":"text","marks":[{"type":"code_inline"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Q: Cookie 过期怎么办?","type":"text"}]},{"type":"paragraph","content":[{"text":"A: 需要 Daniel 通过浏览器登录微信公众号平台,保存 Playwright state:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"openclaw browser open --url https://mp.weixin.qq.com\n# 手动扫码登录后\n# Cookie 会自动保存","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"依赖","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"playwright>=1.40.0\nPillow>=10.0.0 (图片验证)\nmarkdown>=3.4.0 (可选,markdown→html)","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"触发词","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"发布到公众号\"、\"发布微信公众号\"、\"发微信\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"公众号草稿\"、\"wechat publish\"、\"wechat mp\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"公众号发布\"、\"mp.weixin publish\"","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"更新日志","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"v1.0.0","type":"text","marks":[{"type":"strong"}]},{"text":" (2026-04-14): 初始版本","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"基础 Markdown→HTML 转换","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"UEditor 富文本填充","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"封面图上传","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"草稿箱保存","type":"text"}]}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}}]},"metadata":{"date":"2026-06-05","name":"wechat-mp-smart-publish","author":"@skillopedia","source":{"stars":65,"repo_name":"claude-code-skills","origin_url":"https://github.com/aaaaqwq/claude-code-skills/blob/HEAD/skills/wechat-mp-smart-publish/SKILL.md","repo_owner":"aaaaqwq","body_sha256":"bd21a69ba7ef0353a0f4eb63a751554395a5a0bf2f970edea27d657071e8aa33","cluster_key":"7a7e73fbd5af88615731ce9fd435b76ac0e584be61747351632171ca70e613a1","clean_bundle":{"format":"clean-skill-bundle-v1","source":"aaaaqwq/claude-code-skills/skills/wechat-mp-smart-publish/SKILL.md","attachments":[{"id":"b8289060-c4ff-547e-b08c-4396d7ed0522","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/b8289060-c4ff-547e-b08c-4396d7ed0522/attachment.py","path":"scripts/publish.py","size":16329,"sha256":"596d7940eb861990ba74eb6a70366dae3735a0bc51d003e2d13a02e6b4776616","contentType":"text/x-python; charset=utf-8"}],"bundle_sha256":"d9c1911a2b69f669de0ea72dae06c30922e168df043f4e7c9de09675595b2edf","attachment_count":1,"text_attachments":1,"attachment_storage":"skillopedia-attachments-v1","binary_attachments":0,"excluded_attachments":[]},"cluster_size":1,"skill_md_path":"skills/wechat-mp-smart-publish/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"browser-automation-scraping","category_label":"Browser"},"exact_dupes_collapsed_into_this":0},"license":"MIT","version":"v1","category":"browser-automation-scraping","metadata":{"type":"automation","author":"ives-cco","domains":["content","publishing","automation","wechat"],"version":"1.0.0","requires":["playwright","browser-access"]},"import_tag":"clean-skills-v1","description":"微信公众号智能发布全流程:标题优化、排版、封面图、发布。支持 Markdown→微信HTML转换、UEditor排版(15px/#3f3f3f/1.75倍行高)、封面图上传、自动存草稿。基于 Playwright CDP 直连浏览器操作。"}},"renderedAt":1782981514923}

WeChat MP Smart Publish — 公众号自动发布 将 Markdown 文章一键发布到微信公众号草稿箱。 什么时候用 - 有了写好的公众号文章(markdown),需要上传到草稿箱 - 批量发布内容到微信公众号 - 自动化内容分发 pipeline 中的一环 - 其他 agent(小content等)需要发布公众号内容时 不适用 - ❌ 需要直接正式发布(不是草稿)— 当前仅支持存草稿,由人工最终发布 - ❌ 视频内容 — 仅支持图文消息 - ❌ 需要编辑已发布文章 前置条件 | 条件 | 说明 | 检查方法 | |------|------|---------| | Playwright | Python playwright 库 | | | OpenClaw Browser | 浏览器服务运行中 | 或检查 | | 微信 Cookie | Playwright state 文件有效 | | | Cookie 未过期 | cookies 包含 qname 和 uin | 检查 cookie 中 qname 字段 | 输入 Markdown 格式要求 输出 使用方法 方式一:直接运行脚本 方式二:作为模块调用 方式三:Agent 调用(推荐) 其他 agent 通过 sessions send 请小code 执行: 核心流程 排版规范 | 参数 | 值 | |-…