- backends becomes the ordered candidate list [OpenCLI, xiaohongshu-mcp, xhs-cli]; probing order makes the desktop/server split automatic: OpenCLI never probes alive headless, so servers fall through to xiaohongshu-mcp; first fully-usable candidate wins, fixable (warn) candidates only win when nothing is fully usable - xiaohongshu-mcp probing: HTTP reachability of localhost:18060 (proxy-bypassed) + mcporter config presence; guides through `mcporter config add` when half-wired - opencli backend: treat a sleeping extension service worker as ready — verified live that `daemon status` reports disconnected while any real command wakes it; disambiguate "sleeping" vs "never installed" via the Chrome Extensions directory on disk (fixes active_backend flapping between OpenCLI and xhs-cli across doctor runs) - install: desktop installs OpenCLI; server prints the xiaohongshu-mcp guide (binary to ~/.agent-reach/tools/, QR login, mcporter add); xhs-cli is no longer installed by default (upstream unmaintained since 2026-03) but existing installs keep working as the last candidate - skill/references/social.md: xiaohongshu section rewritten as three backend command groups keyed off `doctor --json` active_backend, including the 120s-timeout and login-first caveats for the mcp path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6.1 KiB
社交媒体 & 社区
小红书、Twitter/X、B站、V2EX、Reddit。
小红书 / XiaoHongShu(多后端)
小红书有三个后端,先跑 agent-reach doctor --json 看 xiaohongshu 的 active_backend 是哪个,再用对应命令组。
后端 A:OpenCLI(桌面首选,复用浏览器登录态)
# 搜索笔记
opencli xiaohongshu search "query" -f yaml
# 读笔记正文+互动数据(用搜索结果里的完整 URL,含 xsec_token)
opencli xiaohongshu note "NOTE_URL" -f yaml
# 评论(支持楼中楼)
opencli xiaohongshu comments NOTE_ID -f yaml
# 首页推荐 feed
opencli xiaohongshu feed -f yaml
# 用户主页公开笔记
opencli xiaohongshu user USER_ID -f yaml
要求 Chrome 打开且装了 OpenCLI 扩展。报 AUTH_REQUIRED 说明浏览器里没登录小红书,让用户在 Chrome 里登录一次即可。
后端 B:xiaohongshu-mcp(服务器场景)
# 未登录时:先查状态,再取二维码给用户扫
mcporter call 'xiaohongshu.check_login_status()' --timeout 120000
mcporter call 'xiaohongshu.get_login_qrcode()' --timeout 120000
# 搜索
mcporter call 'xiaohongshu.search_feeds(keyword: "query")' --timeout 120000
# 笔记详情+评论(feed_id 和 xsec_token 从搜索结果取)
mcporter call 'xiaohongshu.get_feed_detail(feed_id: "...", xsec_token: "...")' --timeout 120000
首次调用会自动下载约 150MB 无头浏览器,务必带
--timeout 120000。未登录时 search 会挂死,先 check_login_status。
后端 C:xhs-cli(存量备选,上游 2026-03 起停更)
xhs search "query" # 搜索
xhs read NOTE_ID_OR_URL # 读笔记(必须用搜索结果中的 URL/ID,不能裸 note_id)
xhs comments NOTE_ID_OR_URL # 评论
xhs hot # 热门
xhs feed # 推荐
已知不稳定:
xhs user/xhs user-posts/xhs favorites可能返回 API error(上游停更无人修)。新装用户建议直接走后端 A/B。
通用注意事项
xsec_token 限制: 小红书强制 xsec_token 机制,不能直接用裸 note_id 去读。正确流程:先搜索/feed 拿结果,再用结果中的完整 URL/ID 去读。三个后端都一样。
频率控制: 高频请求(批量搜索、深翻评论)会触发验证码,平台限制无法绕过。每次操作间隔 2-3 秒。
写操作(发帖/评论/点赞): 建议只读。xhs-cli v0.6.x 写操作可能因签名问题返回 406。
Twitter/X (twitter-cli)
稳定命令
# 首页时间线(最稳定)
twitter feed -n 20
# 读取单条推文(含回复)
twitter tweet URL_OR_ID
# 读取长文 / X Article
twitter article URL_OR_ID
# 用户时间线
twitter user-posts @username -n 20
# 用户资料
twitter user @username
可能不稳定的命令
# 搜索推文(Twitter 频繁改 GraphQL 端点,可能 404)
twitter search "query" -n 10
# 如果 search 返回 404,升级 twitter-cli:pipx upgrade twitter-cli
# likes(2024 年后只能看自己的,平台限制)
twitter likes
重要注意事项
安装:
pipx install twitter-cli(确保 v0.8.5+)认证: 推荐用 Cookie-Editor 导出后设置环境变量
TWITTER_AUTH_TOKEN+TWITTER_CT0。自动提取在 SSH/Docker/无头环境不可用。IP 风控: 不要在 VPS/数据中心 IP 上频繁调用,尤其是 followers/following,有封号风险。使用住宅代理或本地环境。
search 可能失效: Twitter 频繁修改 GraphQL API,search 命令可能随时返回 404。如遇到,先
pipx upgrade twitter-cli。如果最新版仍不行,说明上游还没跟上 Twitter 的改动,用twitter feed替代。输出格式: 建议用
--yaml或--json获得结构化输出,对 AI agent 更友好。
B站 / Bilibili
# 获取视频元数据
yt-dlp --dump-json "https://www.bilibili.com/video/BVxxx"
# 下载字幕
yt-dlp --write-sub --write-auto-sub --sub-lang "zh-Hans,zh,en" --convert-subs vtt --skip-download -o "/tmp/%(id)s" "URL"
注意: 服务器 IP 可能遇到 412 错误。使用
--cookies-from-browser chrome或配置代理。
V2EX (公开 API)
无需认证,直接调用公开 API。
热门主题
curl -s "https://www.v2ex.com/api/topics/hot.json" -H "User-Agent: agent-reach/1.0"
节点主题
# node_name 如: python, tech, jobs, qna, programmers
curl -s "https://www.v2ex.com/api/topics/show.json?node_name=python&page=1" -H "User-Agent: agent-reach/1.0"
主题详情
# topic_id 从 URL 获取,如 https://www.v2ex.com/t/1234567
curl -s "https://www.v2ex.com/api/topics/show.json?id=TOPIC_ID" -H "User-Agent: agent-reach/1.0"
主题回复
curl -s "https://www.v2ex.com/api/replies/show.json?topic_id=TOPIC_ID&page=1" -H "User-Agent: agent-reach/1.0"
用户信息
curl -s "https://www.v2ex.com/api/members/show.json?username=USERNAME" -H "User-Agent: agent-reach/1.0"
Python 调用示例
from agent_reach.channels.v2ex import V2EXChannel
ch = V2EXChannel()
# 获取热门帖子
topics = ch.get_hot_topics(limit=10)
for t in topics:
print(f"[{t['node_title']}] {t['title']} ({t['replies']} 回复)")
# 获取节点帖子
node_topics = ch.get_node_topics("python", limit=5)
# 获取帖子详情 + 回复
topic = ch.get_topic(1234567)
print(topic["title"], "—", topic["author"])
# 获取用户信息
user = ch.get_user("Livid")
Reddit (rdt-cli)
# 搜索帖子
rdt search "query" --limit 10
# 读帖子全文 + 评论
rdt read POST_ID
# 浏览 subreddit
rdt sub python --limit 20
# 浏览热门
rdt popular --limit 10
# 浏览 /r/all
rdt all --limit 10
安装:
pipx install 'git+https://github.com/public-clis/rdt-cli.git'(PyPI 版本暂时落后,需从 GitHub 装 v0.4.2+)。需要先登录(rdt login)才能搜索和阅读。 需要登录的功能:rdt feed --subs-only(订阅列表)、rdt saved(收藏)。 建议使用--yaml输出,对 AI agent 更友好。