基于 CDP (Chrome DevTools Protocol) 的 Twitter/X 自动化发布工具,支持发布推文、线程、搜索和互动功能。
本项目灵感来自 xiaohongshu-skills - 小红书自动化发布工具。
感谢原作者的出色设计,本项目的架构和 CLI 设计参考了 xiaohongshu-skills 的模式。
- ✅ 发布单条推文
- ✅ 发布线程(多条推文)
- ✅ 搜索推文
- ✅ 点赞/转发/评论
- ✅ 多账号管理
- ✅ 登录状态检查
- ✅ CDP 连接支持
cd X-Skills
pip3 install -r requirements.txt
playwright install chromiumpython scripts/chrome_launcher.pypython scripts/x_publish.py loginpython scripts/x_publish.py --tweet "这是推文内容"# 有窗口模式(推荐)
python scripts/chrome_launcher.py
# 无头模式
python scripts/chrome_launcher.py --headless
# 指定端口
python scripts/chrome_launcher.py --port 9223
# 重启
python scripts/chrome_launcher.py --restart
# 关闭
python scripts/chrome_launcher.py --kill# 直接发布
python scripts/x_publish.py --tweet "推文内容"
# 从文件读取
python scripts/x_publish.py --tweet-file tweet.txt
# 带图片
python scripts/x_publish.py --tweet "内容" --images pic1.jpg pic2.jpg
# 预览模式(不实际发布)
python scripts/x_publish.py --preview --tweet "内容"# 多条推文
python scripts/x_publish.py --thread "推文 1" "推文 2" "推文 3"
# 从文件读取(每行一条)
python scripts/x_publish.py --thread-file thread.txt# 列出所有账号
python scripts/x_publish.py list-accounts
# 添加新账号
python scripts/x_publish.py add-account work --alias "工作号"
# 切换账号
python scripts/x_publish.py switch-account --account personalX-Skills/
├── README.md # 本文件
├── SKILL.md # 完整使用说明
├── requirements.txt # Python 依赖
├── scripts/
│ ├── chrome_launcher.py # Chrome 启动器
│ └── x_publish.py # Twitter 发布核心
├── config/ # 配置文件
├── docs/ # 详细文档
├── images/ # 图片资源
└── tmp/ # 临时文件
- Python 3.9+
- Playwright - 浏览器自动化
- CDP - Chrome DevTools Protocol
- Twitter Web - 网页版 Twitter
- 登录状态:首次使用需要手动登录(用户名/密码)
- 字符限制:单条推文不超过 280 字符
- 线程限制:单次最多发布 25 条推文
- 图片限制:单条推文最多 4 张图片
- 速率限制:避免短时间内大量发布
欢迎提交 Issue 和 Pull Request!
MIT License
- xiaohongshu-skills - 本项目灵感来源和架构参考
- Playwright - 优秀的浏览器自动化工具
- Twitter - 平台提供方
创建时间: 2026-03-09
版本: 0.1.0
状态: 开发中 🚧