返回顶部
x

xfetchX数据抓取

Use xfetch CLI to fetch X/Twitter data - tweets, user profiles, search results, timelines, lists, DMs, and notifications. Use this skill whenever you need to retrieve any data from X/Twitter, whether the user asks to "get tweets", "look up a Twitter user", "search X for...", "check my timeline", "fetch bookmarks", "read DMs", or any variation involving X/Twitter data retrieval. Also use when the user pastes a tweet URL and wants its content, or asks to export Twitter data to CSV/JSON/SQLite.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
313
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

xfetch

xfetch - X/Twitter CLI 数据抓取工具

xfetch 是一个基于 Cookie 的 X/Twitter 命令行抓取工具。它不需要 API 密钥——只需浏览器 Cookie 即可进行身份验证。它作为 xfetch 全局安装(或可通过 npx @lxgic/xfetch / bunx @lxgic/xfetch 运行)。

前提条件

必须先设置身份验证。使用以下命令检查:

bash
xfetch auth check

如果未通过身份验证,从用户浏览器中提取 Cookie:

bash
xfetch auth extract --browser chrome # 或 firefox, safari, arc, brave
xfetch auth extract --browser chrome --profile Profile 1 # 指定配置文件

或直接设置令牌:

bash
xfetch auth set --auth-token --ct0

命令参考

单条推文

接受推文 URL 或数字 ID:

bash
xfetch tweet https://x.com/user/status/123456789
xfetch tweet 123456789

也支持 X 文章 URL(/article/ID)。

用户资料

bash
xfetch user @handle # 通过用户名(@ 可选)
xfetch user 12345678 # 通过数字 ID

用户推文

bash
xfetch tweets @handle # 最新 20 条推文
xfetch tweets @handle -n 50 # 每页 50 条
xfetch tweets @handle --replies # 包含回复
xfetch tweets @handle --all # 所有页面(分页)
xfetch tweets @handle --max-pages 5 # 限制为 5 页

线程 / 对话

bash
xfetch thread # 完整对话线程

搜索

bash
xfetch search query # 热门结果
xfetch search query --type latest # 最新推文
xfetch search query --type people # 用户结果
xfetch search query --type photos # 图片推文
xfetch search query --type videos # 视频推文
xfetch search from:handle since:2024-01-01 # 高级运算符
xfetch search query -n 100 --all # 所有页面

搜索类型:top(默认)、latest、people、photos、videos。

时间线

bash
xfetch home # 算法推荐首页时间线
xfetch home --following # 按时间顺序(仅关注)
xfetch bookmarks # 你的书签
xfetch likes @handle # 用户点赞的推文

关注者 / 关注

bash
xfetch followers @handle -n 100
xfetch following @handle -n 100

列表

bash
xfetch lists @handle # 用户的列表
xfetch list # 列表详情
xfetch list-members # 列表成员
xfetch list-tweets -n 50 # 列表时间线

私信

bash
xfetch dms # 收件箱概览
xfetch dms inbox # 同上
xfetch dms conversation # 对话中的消息
xfetch dms # 上述命令的快捷方式

通知

bash
xfetch notifications # 所有通知
xfetch mentions # 仅提及
xfetch verified-notifications # 来自认证账户

身份验证管理

bash
xfetch auth check # 显示身份验证状态
xfetch auth extract --browser chrome # 提取 Cookie
xfetch auth set --auth-token --ct0 # 手动设置令牌
xfetch auth clear # 清除保存的身份验证
xfetch auth browsers # 列出可用浏览器和配置文件

查询 ID 管理

bash
xfetch query-ids --refresh # 从 X 前端获取最新查询 ID
xfetch query-ids --list # 显示缓存的查询 ID

分页选项

所有列表类命令(tweets、search、followers、following、likes、bookmarks、home、notifications、mentions、list-members、list-tweets、dms inbox、dms conversation)都支持以下分页选项:

标志描述
-n, --count <N>每页结果数(默认:20)
--all
获取所有可用页面 |
| --max-pages | 最大获取页数 |
| --cursor | 从指定游标恢复 |
| --resume | 将游标状态保存/恢复到文件 |
| --delay | 页面请求之间的延迟(默认:1000ms) |

输出格式

使用 --format 控制输出:

bash
xfetch tweets @handle --format json # 美化打印的 JSON(默认)
xfetch tweets @handle --format jsonl # 换行分隔的 JSON(流式)
xfetch tweets @handle --format csv # 带标题的 CSV
xfetch tweets @handle --format sqlite --db tweets.db # SQLite 数据库

额外输出标志:

  • - --json — --format json 的简写
  • --plain — 禁用美化打印

使用 shell 重定向管道到文件:
bash
xfetch tweets @handle -n 100 --format csv > tweets.csv
xfetch search AI --all --format jsonl > results.jsonl

全局选项

这些选项可传递给任何命令:

标志描述
--auth-token <token>覆盖 auth_token Cookie
--ct0 <token>
覆盖 ct0 Cookie |
| --cookie-source | Cookie 来源浏览器 |
| --chrome-profile | Chrome 配置文件名称 |
| --proxy | 代理 URL(http://user:pass@host:port) |
| --proxy-file | 包含代理 URL 的文件,用于轮换 |
| --timeout | 请求超时(默认:30000) |
| --delay | 请求之间的延迟(默认:500) |
| --no-color | 禁用彩色输出 |

有效使用技巧

  • - 获取大型数据集时,建议使用 --format jsonl 进行流式输出(避免在内存中缓冲整个结果集)。
  • 当只需要样本数据时,使用 --max-pages 而不是 --all——速度更快且避免速率限制。
  • 如果请求失败并显示 404 或查询 ID 错误,请尝试 xfetch query-ids --refresh 更新缓存的查询 ID——X 会定期轮换这些 ID。
  • 通过 jq 管道处理 JSON 输出进行过滤:xfetch tweets @handle | jq .[].text
  • 对于 SQLite 输出,始终指定 --db:xfetch tweets @handle --format sqlite --db data.db
  • 速率限制在内部通过抖动处理,但高容量抓取建议使用 --delay 2000 或更高值。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 xfetch-1776200545 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 xfetch-1776200545 技能

通过命令行安装

skillhub install xfetch-1776200545

下载

⬇ 下载 xfetch v1.0.0(免费)

文件大小: 2.99 KB | 发布时间: 2026-4-15 11:51

v1.0.0 最新 2026-4-15 11:51
Initial release of xfetch – a CLI tool for scraping and exporting X/Twitter data using browser cookies.

- Fetch tweets, user profiles, threads, timelines, lists, DMs, and notifications via simple CLI commands.
- Flexible authentication using browser cookie extraction or manual token entry.
- Extensive pagination and formatting options: output as JSON, JSONL, CSV, or directly to SQLite.
- Supports timeline, search, user lookup, likes, bookmarks, lists, followers, DMs, and notifications.
- Includes options for proxies, request delay, color control, and error recovery via query ID refresh.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部