toutiao-publisher
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseToutiao Publisher Skill
头条号发布Skill
Manage Toutiao (Today's Headlines) account, maintain persistent login session, and publish articles.
管理头条号(今日头条)账号,维护持久化登录会话并发布文章。
When to Use This Skill
何时使用该Skill
Trigger when user:
- Asks to publish to Toutiao/Today's Headlines
- Wants to manage Toutiao login
- Mentions "toutiao" or "头条号"
当用户有以下需求时触发:
- 请求发布文章至头条号/今日头条
- 想要管理头条号登录状态
- 提及“toutiao”或“头条号”
Core Workflow
核心工作流程
Step 1: Authentication (One-Time Setup)
步骤1:认证(一次性设置)
The skill requires a one-time login. The session is persisted for subsequent uses.
bash
undefined该Skill仅需一次登录,会话将被持久化以便后续使用。
bash
undefinedBrowser will open for manual login (scan QR code)
Browser will open for manual login (scan QR code)
python scripts/run.py auth_manager.py setup
**Instructions:**
1. Run the setup command.
2. A browser window will open loading the Toutiao login page.
3. Log in manually (e.g., scan QR code).
4. Once logged in (redirected to dashboard), the script will save the session and close.python scripts/run.py auth_manager.py setup
**操作说明:**
1. 运行设置命令。
2. 浏览器窗口将打开并加载头条号登录页面。
3. 手动登录(例如扫码登录)。
4. 登录成功后(跳转至后台管理页),脚本将保存会话并关闭浏览器。Step 2: Publish Article
步骤2:发布文章
bash
undefinedbash
undefinedOpens browser with authenticated session at publish page
Opens browser with authenticated session at publish page
python scripts/run.py publisher.py
**Instructions:**
1. Run the publisher command.
2. Browser opens directly to the "Publish Article" page.
3. Write and publish the article manually.
4. 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).python scripts/run.py publisher.py
**操作说明:**
1. 运行发布命令。
2. 浏览器将直接打开「发布文章」页面。
3. 手动撰写并发布文章。
4. 完成后在终端中按下`Ctrl+C`。
> **注意:** 头条号要求标题长度为**2-30字符**。该工具会自动优化标题以符合此限制(超过30字符则截断,不足2字符则补充)。Advanced Usage (Automated)
高级用法(自动化)
You can fully automate the publishing process by providing arguments:
bash
undefined你可以通过传入参数实现发布流程的完全自动化:
bash
undefinedPublish with title, content file, and cover image
Publish with title, content file, and cover image
python scripts/run.py publisher.py --title "AI Trends 2025" --content "article.md" --cover "assets/cover.jpg" --headless
undefinedpython scripts/run.py publisher.py --title "AI Trends 2025" --content "article.md" --cover "assets/cover.jpg" --headless
undefinedManagement
管理功能
bash
undefinedbash
undefinedCheck authentication status
Check authentication status
python scripts/run.py auth_manager.py status
python scripts/run.py auth_manager.py status
Clear authentication data (logout)
Clear authentication data (logout)
python scripts/run.py auth_manager.py clear
undefinedpython scripts/run.py auth_manager.py clear
undefinedTechnical Details
技术细节
- Persistent Auth: Uses to launch a persistent browser context. Cookies and storage state are saved to
patchright.data/browser_state/state.json - Anti-Detection: Uses 's stealth features to avoid bot detection.
patchright - Environment: Automatically manages a virtual environment () with required dependencies.
.venv
- 持久化认证:使用启动持久化浏览器上下文,Cookie和存储状态将保存至
patchright。data/browser_state/state.json - 反检测:利用的隐身特性避免被识别为机器人。
patchright - 环境管理:自动管理包含所需依赖的虚拟环境()。
.venv
Script Reference
脚本参考
- : Handles login, session validation, and state persistence.
scripts/auth_manager.py - : Launches authenticated browser for publishing.
scripts/publisher.py - : Wrapper ensuring execution in the correct virtual environment.
scripts/run.py
- :处理登录、会话验证和状态持久化。
scripts/auth_manager.py - :启动已认证的浏览器进行发布操作。
scripts/publisher.py - :确保脚本在正确虚拟环境中执行的包装器。
scripts/run.py