AI Agent 抓推特终于不用登录了!这个 OpenClaw 技能零配置搞定
Source: Dev.to
AI Agent 抓推特终于不用登录了!这个 OpenClaw 技能零配置搞定
AI Agent 想读推特,你会怎么做?
- 申请 Twitter API?每月 $100+。
- 用爬虫?分分钟被封。
- 手动复制粘贴?那还要 AI 干嘛。
x‑tweet‑fetcher 解决这个问题:一个 OpenClaw 技能,零配置抓取推文。无需 API key、登录或 Cookie,一条命令即可得到 JSON 输出,直接供 Agent 使用。
它能做什么
基础功能(零依赖)
# 抓取单条推文
python3 scripts/fetch_tweet.py --url "https://x.com/user/status/123456"
输出示例:
{
"text": "推文内容...",
"likes": 91,
"retweets": 23,
"views": 14468,
"media": ["图片URL"],
"quoted_tweet": {...}
}
支持的内容类型:
- 普通推文(完整文本 + 数据)
- 长推文(Twitter Blue)
- X Articles(长文章)
- 引用推文
- 数据统计(点赞/转发/浏览量)
高级功能(需要 Camofox)
# 回复评论(线程化)
python3 scripts/fetch_tweet.py --url "URL" --replies
# 用户时间线(最多 200 条)
python3 scripts/fetch_tweet.py --user elonmusk --limit 50
# X Lists
python3 scripts/fetch_tweet.py --list "https://x.com/i/lists/123456"
# 监控 @mentions(Cron 友好)
python3 scripts/fetch_tweet.py --monitor @username
退出码设计:
0– 无新内容1– 有新内容2– 错误
完美适配 Cron 自动化。
不只是推特
微信公众号搜索
python3 scripts/sogou_wechat.py --keyword "AI Agent" --limit 10 --json
输出:标题、URL、作者、日期。无需 API key,直接使用搜狗搜索。
推文发现
python3 scripts/x_discover.py --keywords "AI Agent,LLM tools" --limit 5 --json
使用 DuckDuckGo(或 Camofox Google 备用)进行关键词搜索。
中文平台
python3 scripts/fetch_china.py --url "微博/B站/CSDN/微信链接"
自动识别平台,统一返回 JSON。
Python 模块导入
from scripts.fetch_tweet import fetch_tweet
# 抓取推文
tweet = fetch_tweet("https://x.com/user/status/123456")
print(tweet["text"])
# 搜索微信公众号
from scripts.sogou_wechat import sogou_wechat_search
articles = sogou_wechat_search("AI Agent", max_results=10)
# 发现推文
from scripts.x_discover import discover_tweets
result = discover_tweets(["AI Agent"], max_results=5)
Agent 可直接调用,无需额外封装。
Cron 自动化
# 每 30 分钟检查 @mentions
*/30 * * * * python3 fetch_tweet.py --monitor @username || notify-send "New mentions!"
# 每天早上 9 点发现新推文
0 9 * * * python3 x_discover.py --keywords "AI Agent" --json >> ~/discoveries.jsonl
利用退出码 0/1/2,实现精准的自动化流程。
技术原理
基础推文
使用 FxTwitter 公共 API:无需认证,直接 HTTP 请求,返回结构化 JSON。
高级功能
Camofox(基于 Camoufox 的无头浏览器)提供:
- C++ 级别指纹伪装
- 绕过 Google、Cloudflare、反爬虫检测
Nitter 解析用于补充 FxTwitter API 未提供的浏览量等信息。
微信搜索
通过 搜狗搜索 的 HTTP 接口,返回标题、URL、作者、日期,无需浏览器渲染。
安装
基础功能(零依赖)
git clone https://github.com/ythx-101/x-tweet-fetcher.git
python3 scripts/fetch_tweet.py --url "URL"
高级功能(需要 Camofox)
# 方式 1:OpenClaw 插件
openclaw plugins install @askjo/camofox-browser
# 方式 2:独立安装
git clone https://github.com/jo-inc/camofox-browser
cd camofox-browser && npm install && npm start # 端口 9377
为什么选它
| 工具 | 需要登录 | 需要 API Key | 支持平台 | 价格 |
|---|---|---|---|---|
| Twitter API | ✅ | ✅ | 仅推特 | $100+/月 |
| xfetch | ✅ (Cookie) | ❌ | 仅推特 | 免费 |
| x‑tweet‑fetcher | ❌ | ❌ | 推特、微信、中文平台(微博、B 站、CSDN) | 免费 |
核心优势
- 零配置(无需 API key、登录、Cookie)
- Agent 友好(JSON 输出,Python 模块)
- Cron 友好(退出码设计)
- 多平台支持(推特、微信、微博、B 站、CSDN)
- 反爬虫(Camofox 指纹伪装)
使用场景
-
AI Agent 数据收集
from scripts.fetch_tweet import fetch_tweet tweet = fetch_tweet(url) agent.process(tweet["text"]) -
内容监控
*/30 * * * * python3 fetch_tweet.py --monitor @competitor -
竞品分析
python3 scripts/fetch_tweet.py --user competitor --limit 100 -
内容创作
python3 scripts/x_discover.py --keywords "AI,LLM" --limit 20 -
学术研究
tweets = [fetch_tweet(u) for u in urls] analyze(tweets)
最新更新
-
v1.6.2(2026-03-04)
- 从 Nitter 提取
tweet_id - 通过 FxTwitter API 补充浏览量
- 从 Nitter 提取
-
v1.6.1(2026-03-04)
- Lists 解析修复
- 新增
retweeted_by和quoted_tweet字段
-
v1.6.0(2026-03-04)
- X Lists 抓取
项目活跃维护,持续更新。
开源
- GitHub:
- Stars: 343
- Forks: 27
- 许可证: MIT
总结
AI Agent 抓取推特再也不需要申请昂贵的 API、手动登录或编写易被封的爬虫。使用 x‑tweet‑fetcher,实现零配置、零成本、零维护,一键获取推特、微信及中文平台的内容。
git clone https://github.com/ythx-101/x-tweet-fetcher.git
python3 scripts/fetch_tweet.py --url "URL"
一个工具,全搞定。