{"id":51468442,"url":"https://github.com/lichtcui/trending-bot","last_synced_at":"2026-07-06T14:01:16.229Z","repository":{"id":369211285,"uuid":"1288890103","full_name":"lichtcui/trending-bot","owner":"lichtcui","description":"GitHub Trending scraper + Feishu bot notifier","archived":false,"fork":false,"pushed_at":"2026-07-04T05:01:00.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-07-04T07:06:46.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lichtcui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-07-04T04:53:21.000Z","updated_at":"2026-07-04T05:01:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lichtcui/trending-bot","commit_stats":null,"previous_names":["lichtcui/trending-bot"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/lichtcui/trending-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichtcui%2Ftrending-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichtcui%2Ftrending-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichtcui%2Ftrending-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichtcui%2Ftrending-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lichtcui","download_url":"https://codeload.github.com/lichtcui/trending-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichtcui%2Ftrending-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35193679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-06T14:01:15.105Z","updated_at":"2026-07-06T14:01:16.219Z","avatar_url":"https://github.com/lichtcui.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔥 trending-bot\n\n**GitHub Trending 爬虫 · AI 友好的结构化 JSON 输出**\n\n每日自动抓取 GitHub Trending 热门项目，输出结构化 JSON 数据，适合 AI Agent、CI 流水线及其他自动化工具消费。内置增量缓存——只输出新上榜的项目，重复内容自动跳过。\n\n## 特性\n\n- **自动抓取** — 爬取 GitHub Trending 每日热门项目，CSS 选择器解析，支持 `k`/`m` 星数后缀\n- **增量缓存** — 本地缓存历史记录，只输出新上榜单的项目，避免重复消费\n- **AI 友好输出** — 结构化 JSON 包含缓存对比结果，AI Agent 可直接集成\n- **简洁依赖** — 仅依赖 `reqwest`、`scraper`、`serde`、`chrono`、`rss`，轻量无冗余\n- **周一加餐** — 周一自动追加 This Week in Rust、ByteByteGo、AI Weekly 三个 Newsletter 源，覆盖六个数据源\n- **跨平台** — Linux / macOS / Docker 均可运行\n\n## 快速开始\n\n### 前置条件\n\n- Rust 1.60+\n\n### 安装\n\n```bash\n# 克隆仓库\ngit clone https://github.com/lichtcui/trending-bot.git\ncd trending-bot\n\n# 构建\ncargo build --release\n\n# 二进制文件在 target/release/trending-bot\n```\n\n### 运行\n\n```bash\n# 默认获取 Top 5 项目，输出到控制台\ncargo run --release\n\n# 获取 Top 10 项目\ncargo run --release -- --count 10\n\n# JSON 输出（适合 AI Agent 或其他工具消费）\ncargo run --release -- --json\n\n# 预览模式（不更新本地缓存）\ncargo run --release -- --dry-run\n\n# 组合使用\ncargo run --release -- --json --count 10 --dry-run\n```\n\n## CLI 参数\n\n| 参数 | 描述 |\n|------|------|\n| `--count N` / `-c N` | 获取前 N 个项目（默认 5） |\n| `--json` | 输出结构化 JSON（包含缓存对比结果） |\n| `--dry-run` | 预览模式，不更新本地缓存 |\n\n## 项目架构\n\n```\nsrc/\n├── main.rs       # 入口：CLI 参数解析、编排获取→缓存→输出流程\n├── source.rs     # TrendingSource trait + GitHubTrending 实现\n├── rss.rs        # RSS 源解析（Rust Weekly / ByteByteGo / AI Weekly）\n├── hn.rs         # HackerNews 数据源\n├── lobsters.rs   # Lobsters 数据源\n├── item.rs       # TrendingItem 统一数据模型\n├── fetcher.rs    # ContentFetcher 外部链接内容抓取\n├── cache.rs      # 本地缓存管理器（增量对比 / 持久化）\n├── output.rs     # AI 可消费的结构化 JSON 输出\n├── summary.rs    # DeepSeek LLM 总结\n└── repo.rs       # Repo 旧模型与 Star 数解析\n```\n\n### 数据流\n\n```\nGitHub Trending 页面\n        ↓ (HTTP 请求 + HTML 解析)\n    Repo 列表\n        ↓ (与本地缓存对比)\n   ├─ 旧项目（已在缓存中）→ 跳过标记\n   └─ 新项目（不在缓存中）→ 新项目标记\n        ↓\n    结构化 JSON 输出（stdout）\n        ↓\n    更新本地缓存\n```\n\n## JSON 输出格式\n\n```json\n{\n  \"tool\": \"trending-bot\",\n  \"version\": \"0.1.0\",\n  \"fetched_at\": \"2026-07-04T12:00:00+08:00\",\n  \"count\": 5,\n  \"repos\": [\n    {\n      \"name\": \"rust-lang/rust\",\n      \"url\": \"https://github.com/rust-lang/rust\",\n      \"description\": \"Empowering everyone to build reliable...\",\n      \"language\": \"Rust\",\n      \"stars_total\": 101234,\n      \"stars_today\": 567\n    }\n  ],\n  \"cache\": {\n    \"status\": \"partial_update\",\n    \"new_count\": 2,\n    \"old_count\": 3,\n    \"new_repos\": [\"owner/new-a\", \"owner/new-b\"],\n    \"is_duplicate\": false\n  }\n}\n```\n\n### `cache.status` 取值\n\n| 值 | 含义 |\n|----|------|\n| `all_new` | 缓存为空或全部是新项目 |\n| `partial_update` | 部分项目是新的 |\n| `no_change` | 所有项目与上次一致 |\n\n## AI Agent 集成示例\n\n```bash\n# 作为 MCP 工具或自定义 Agent 工具调用\ncargo run --release -- --json --count 10\n```\n\n输出可以直接注入 LLM 上下文，Agent 可根据 `cache` 字段判断是否有新项目、哪些是新项目，避免重复处理。\n\n## 缓存策略\n\n缓存文件位于 `~/Library/Caches/trending-bot/last_repos.json`，格式如下：\n\n```json\n{\n  \"date\": \"2026-07-04\",\n  \"names\": [\"owner/repo-a\", \"owner/repo-b\"]\n}\n```\n\n- **首次运行**：缓存不存在，视为全量更新（`all_new`）\n- **重复数据**：只有部分重复或全部重复时，分别触发 `partial_update` 或 `no_change`\n- **缓存损坏**：自动提示手动删除\n\n## 测试\n\n```bash\n# 运行所有测试\ncargo test\n\n# 运行不包含网络请求的测试（跳过 ignore 标记的集成测试）\ncargo test -- --ignored\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flichtcui%2Ftrending-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flichtcui%2Ftrending-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flichtcui%2Ftrending-bot/lists"}