📝 Toutiao Publisher 使用总结

1️⃣ 环境准备

# 确保使用 Python 3.8+
python3.8 –version # 确认 3.8+

清理旧环境(如果是首次)

rm -rf /root/.openclaw/workspace/skills/.agents/skills/toutiao-publisher/.venv

2️⃣ 认证登录(3种方式)

方式 A:导入 Cookie(最快)

# 转换 cookie.json 为 state.json
python3.8 scripts/convert_cookies.py

或直接调用 import 命令

python3.8 scripts/run.py auth_manager.py import_cookies /path/to/cookie.json

方式 B:扫码登录(需图形环境)

# 有 X server
python3.8 scripts/run.py auth_manager.py setup

无图形但可用截图

python3.8 scripts/run.py auth_manager.py setup –headless

查看 data/screenshots/ 中的二维码截图

方式 C:xvfb-run(虚拟显示)

xvfb-run python3.8 scripts/run.py auth_manager.py setup

3️⃣ 验证状态

python3.8 scripts/run.py auth_manager.py status

应显示: Authenticated: Yes

4️⃣ 发布文章

python3.8 scripts/run.py publisher.py \
–title “你的标题(2-30字)” \
–content “/absolute/path/article.md” \
–cover “/absolute/path/cover.jpg” \
–headless # 服务器环境必须加

content:文章路径
headless:图片路径

5️⃣ 常见问题

问题

解决方法

ModuleNotFoundError: patchright

python3.8(非 python3.6

ERROR: Could not find a version (deps)

修改 requirements.txtpatchright==1.48.0.post0

Missing X server

--headless 或用 xvfb-run

二维码过期

用 import_cookies 或定期截图

标题超长

脚本自动截断,确保30字内

6️⃣ 文件位置建议

skills/.agents/skills/toutiao-publisher/
├── content/
│ ├── Article/ # 存放 .md 文章
│ └── Picture/ # 存放封面 .jpg/.png
├── scripts/
└── data/
└── browser_state/
├── state.json # 认证状态(自动生成)
└── screenshots/ # 扫码截图(仅 headless 时)



本站使用 Stellar 1.33.1 主题创建。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。