Toutiao Publisher Skill
Manage Toutiao (Today's Headlines) account, maintain persistent login session, and publish articles.
When to Use This Skill
Trigger when user:
- - Asks to publish to Toutiao/Today's Headlines
- Wants to manage Toutiao login
- Mentions "toutiao" or "头条号"
Core Workflow
Step 1: Authentication (One-Time Setup)
The skill requires a one-time login. The session is persisted for subsequent uses.
CODEBLOCK0
Instructions:
- 1. Run the setup command.
- A browser window will open loading the Toutiao login page.
- Log in manually (e.g., scan QR code).
- Once logged in (redirected to dashboard), the script will save the session and close.
Step 2: Publish Article
CODEBLOCK1
Instructions:
- 1. Run the publisher command.
- Browser opens directly to the "Publish Article" page.
- Write and publish the article manually.
- Press
Ctrl+C in the terminal when done.
Note: Toutiao requires titles to be 2-30 characters. This tool automatically optimizes titles to fit this constraint (truncating if >30, padding if <2).
Advanced Usage (Automated)
You can fully automate the publishing process by providing arguments:
CODEBLOCK2
Management
CODEBLOCK3
Technical Details
- - Persistent Auth: Uses
patchright to launch a persistent browser context. Cookies and storage state are saved to data/browser_state/state.json. - Anti-Detection: Uses
patchright's stealth features to avoid bot detection. - Environment: Automatically manages a virtual environment (
.venv) with required dependencies.
Script Reference
- -
scripts/auth_manager.py: Handles login, session validation, and state persistence. - INLINECODE6 : Launches authenticated browser for publishing.
- INLINECODE7 : Wrapper ensuring execution in the correct virtual environment.
头条号发布技能
管理今日头条账号,保持持久登录会话,并发布文章。
何时使用此技能
当用户出现以下情况时触发:
- - 要求发布到今日头条
- 想要管理头条号登录
- 提及头条或头条号
核心工作流程
第一步:身份验证(一次性设置)
该技能需要一次性登录。会话将持久保存以供后续使用。
bash
浏览器将打开供手动登录(扫描二维码)
python scripts/run.py auth_manager.py setup
操作说明:
- 1. 运行设置命令。
- 浏览器窗口将打开,加载头条登录页面。
- 手动登录(例如,扫描二维码)。
- 登录成功后(重定向到控制台),脚本将保存会话并关闭。
第二步:发布文章
bash
在发布页面打开已认证会话的浏览器
python scripts/run.py publisher.py
操作说明:
- 1. 运行发布命令。
- 浏览器直接打开发布文章页面。
- 手动编写并发布文章。
- 完成后在终端按Ctrl+C。
注意: 头条要求标题为2-30个字符。此工具会自动优化标题以符合此限制(超过30个字符则截断,少于2个字符则填充)。
高级用法(自动化)
您可以通过提供参数完全自动化发布流程:
bash
使用标题、内容文件和封面图片发布
python scripts/run.py publisher.py --title AI趋势2025 --content article.md --cover assets/cover.jpg --headless
管理
bash
检查身份验证状态
python scripts/run.py auth_manager.py status
清除身份验证数据(退出登录)
python scripts/run.py auth_manager.py clear
技术细节
- - 持久认证:使用patchright启动持久浏览器上下文。Cookie和存储状态保存到data/browser_state/state.json。
- 反检测:使用patchright的隐身功能避免机器人检测。
- 环境:自动管理包含所需依赖的虚拟环境(.venv)。
脚本参考
- - scripts/auth_manager.py:处理登录、会话验证和状态持久化。
- scripts/publisher.py:启动已认证的浏览器用于发布。
- scripts/run.py:确保在正确的虚拟环境中执行的包装器。