自动化与脚本
需要一条命令抓取 55+ 网站实时数据、控制…
当你要用命令行快速获取 Twitter/Reddit/YouTube/Bilibili/知乎等站点的实时数据,或让 AI Agent 统一调用外部 CLI 与桌面应用时,安装并使用 opencli-rs。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
需要一条命令抓取 55+ 网站实时数据、特定
解决思路
- 安装二进制(macOS/Linux 一行脚本):`curl -fsSL https://raw.githubusercontent.com/nashsu/opencli-rs/main/scripts/install.sh | sh`
- 安装二进制(Windows PowerShell):下载 `opencli-rs-x86_64-pc-windows-msvc.zip` 到 `opencli-rs.zip`,用 `Expand-Archive` 解压,再 `Move-Item opencli-rs.exe "$env:LOCALAPPDATA\Microsoft\WindowsApps\"`
- 从源码编译:`git clone https://github.com/nashsu/opencli-rs.git`,`cd opencli-rs`,`cargo build --release`,`cp target/release/opencli-rs /usr/local/bin/`
- 安装 Chrome 扩展(Browser 模式命令必需):从 GitHub Releases 下载 `opencli-rs-chrome-extension.zip` 并解压到任意目录;打开 `chrome://extensions` → 开启 Developer mode → Load unpacked → 选择解压目录;扩展会自动连接 opencli-rs daemon
- 作为 AI Agent Skill 安装:`npx skills add https://github.com/nashsu/opencli-rs-skill`
- 按依赖条件选择命令模式:Public(无需任何前置,直接调公开 API,如 hackernews/devto/arxiv/wikipedia)、Browser(需 Chrome + 扩展运行中,如 twitter/bilibili/reddit/zhihu)、Desktop(需目标 Electron 应用运行中,如 cursor/chatgpt/notion/discord)
- 使用全局 flag:`opencli-rs --help` 列出所有命令、`opencli-rs <site> --help` 看站点帮助、`--format json|yaml|csv|markdown|table` 指定输出、`--limit 20` 限制条数、`opencli-rs doctor` 跑诊断、`opencli-rs completion bash >> ~/.bashrc` 生成补全(支持 bash/zsh/fish)
- 调用 Public 命令抓公开数据:`opencli-rs hackernews top --limit 10`、`opencli-rs hackernews search "rust async" --limit 5`、`opencli-rs hackernews user pg`、`opencli-rs arxiv search "large language models" --limit 10`、`opencli-rs arxiv paper 2303.08774`、`opencli-rs wikipedia summary "Rust programming language"`、`opencli-rs wikipedia search "memory safety"`、`opencli-rs wikipedia random`、`opencli-rs stackoverflow hot`、`opencli-rs stackoverflow search "tokio async runtime"`、`opencli-rs devto top`、`opencli-rs devto tag rust`、`opencli-rs linux-do hot`、`opencli-rs linux-do search "Rust"`
- 调用 Browser 命令抓需登录的站点(复用浏览器会话):Twitter/X 用 `opencli-rs twitter search|trending|timeline|bookmarks|profile <user>|post "..."|follow rustlang`;Bilibili 用 `opencli-rs bilibili hot --limit 20|search|ranking|feed|download <video_url>`;Reddit 用 `opencli-rs reddit frontpage|popular|subreddit rust|search|upvote <post_id>`;知乎用 `opencli-rs zhihu hot|search "Rust 内存安全"|question 12345`;小红书用 `opencli-rs xiaohongshu search|feed|user <user_id>`;YouTube 用 `opencli-rs youtube search|video <id>|transcript <video_id>`;微博用 `opencli-rs weibo hot|search`;豆瓣用 `opencli-rs douban top250|search|movie-hot`;Medium 用 `opencli-rs medium search|feed|user graydon_hoare`;雪球用 `opencli-rs xueqiu hot-stock|search|stock SH600519`
- 控制 Electron 桌面应用:Cursor 用 `opencli-rs cursor status|send "..."|read|ask "..."|screenshot|extract-code|model`;ChatGPT 桌面版用 `opencli-rs chatgpt new|send "..."|read`;Notion 用 `opencli-rs notion search|read <page_id>|write <page_id> "..."|sidebar`;Discord 用 `opencli-rs discord-app channels|send "..."|read`
- 透传外部 CLI:`opencli-rs gh repo list|pr list|issue create --title "..."`、`opencli-rs docker ps|images|logs my-container`、`opencli-rs kubectl get pods|get services -n production|logs <pod-name>`
- 用 AI 发现命令自动摸清站点 API:`opencli-rs explore https://example.com` 探索 API 面、`opencli-rs cascade https://api.example.com/data` 自动探测认证策略、`opencli-rs generate https://example.com --goal "hot posts"` 自动生成适配器、`opencli-rs synthesize https://news.example.com` 从已发现 API 合成适配器
- 选择输出格式:默认 ASCII table;`--format json` 便于管道给 jq;`--format yaml`;`--format csv > hn_top.csv` 给表格软件;`--format markdown` 给文档
- 用声明式 YAML pipeline 自定义适配器(不写 Rust):在 `~/.config/opencli-rs/adapters/my-site.yaml` 写 `name`、`description`、`base_url`、`commands`(含 `endpoint`、`method`、`params` 如 `flag: --limit`/`default: 10`/`query_param: count`、`response.items_path: $.data.posts` 与 `fields` 的 `name`/`path` 映射);然后 `opencli-rs my-site top --limit 20 --format json` 使用它
- 实战:把 JSON 输出管道给 jq 过滤,如 `opencli-rs hackernews top --limit 20 --format json | jq -r '.[].title'`、`opencli-rs twitter trending --format json | jq -r '.[].name'`、`opencli-rs bilibili ranking --format json | jq '[.[] | select(.view > 1000000)]'`
- 实战:写 shell 脚本做每日摘要(依次调用 `opencli-rs hackernews top --limit 5 --format table`、`bilibili hot`、`zhihu hot`)
- 实战:导出到文件,如 `opencli-rs reddit popular --format csv > reddit_$(date +%Y%m%d).csv`、`opencli-rs hackernews top --format json > hn_top.json`
- 实战:在 Rust 项目里用 `std::process::Command` 调 `opencli-rs` 子进程,读取 stdout 并用 `serde_json::from_slice` 解析;失败时读 stderr 并 `bail!`
- 实战:在 AGENT.md/.cursorrules 中登记工具,写明用 `opencli-rs list` 发现命令,并列出抓取类(hackernews/twitter/arxiv/reddit --format json)与本地 CLI 类(gh/docker/kubectl)命令;自定义工具用 `opencli-rs register mycli` 注册
- 配置:编辑 `~/.config/opencli-rs/config.toml`(Windows 为 `%APPDATA%\opencli-rs\config.toml`),设置 `adapter_dir`、`default_format`、`default_limit`
- 配置:注册自定义外部 CLI 做透传,`opencli-rs register mycli`,之后即可 `opencli-rs mycli --help`、`opencli-rs mycli some-command --flag value`
- 排查:先跑 `opencli-rs doctor`;Chrome 扩展未连接时检查 `chrome://extensions` 中扩展已加载、Developer mode 为 ON、重装 opencli-rs 后重新加载扩展,并确认 daemon 在运行
- 排查:Browser 命令返回空或认证错误时,打开 Chrome 确认已登录目标站点(扩展复用现有会话,无需 token),刷新目标站点标签页后重试
- 排查:安装后找不到二进制时用 `which opencli-rs` / `ls /usr/local/bin/opencli-rs` 确认位置,缺失则 `export PATH="/usr/local/bin:$PATH"` 并写进 `~/.zshrc`
- 排查:源码编译报错时先 `rustup update stable`、按需 `rustup target add aarch64-apple-darwin`,再 `cargo build --release`
- 排查:命令慢或超时时,注意 Browser 命令必须有 Chrome + 扩展否则会挂起,用 `opencli-rs doctor` 验证扩展连通性;Public 命令(hackernews、arxiv 等)无需浏览器,约 1-2 秒完成
- 排查:Windows 路径问题用 `Get-Command opencli-rs` 确认位置,找不到则 `$env:PATH += ";$env:LOCALAPPDATA\Microsoft\WindowsApps"`
- 按分类选用受支持站点:科技新闻 HackerNews/Dev.to/Lobsters/Linux-do;社交 Twitter/X/Reddit/Facebook/Instagram/TikTok/Jike;视频 YouTube/Bilibili/Weixin;中文 知乎/小红书/微博/豆瓣/雪球/微信读书/新浪博客/新浪财经;研究 arXiv/Hugging Face;金融 Yahoo Finance/Barchart/雪球;招聘 Boss/LinkedIn;阅读 Medium/Substack/Wikipedia/BBC/Bloomberg/Reuters;购物 Steam/SMZDM/携程/Coupang;AI 与桌面 Cursor/ChatGPT/Codex/Doubao/ChatWise/Notion/Discord;播客 Apple Podcasts/小宇宙;外部 CLI gh/docker/kubectl/obsidian/readwise/gws
适用边界 · 注意事项
- 目标站点不在内置 55+ 支持列表、且没有可用公开 API 时,不能即开即用,必须先自己写 YAML 适配器或跑 explore/generate/synthesize。
- 不想安装 Chrome 扩展、或环境里无法运行 Chrome 时,不要用 Browser 模式命令(twitter/bilibili/reddit/zhihu 等),会挂起或返回空。
- 只想要极简、无额外二进制与扩展依赖的纯公开 API 抓取时,可用更轻量的方式,不必引入本工具及其 daemon。