Skip to content

Commit 88b7957

Browse files
committed
refactor: 项目整体优化
- 添加 github_trending_*.md 到 .gitignore - 移除 data_pusher.py 中 commit message 的 emoji - 统一代码中的日志输出格式,使用 [START]/[ERROR]/[WARN]/[DONE] 标签 - 使用 logo.svg 作为 favicon - 优化 README.md,移除不必要的 emoji,增加命令行参数说明 - 删除临时文件
1 parent b92d8c2 commit 88b7957

6 files changed

Lines changed: 71 additions & 52 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ build/
1919

2020
# Output
2121
output/
22+
github_trending_*.md
2223

2324
# IDE
2425
.idea/

README.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# 📈 GitHub Trending Reporter
1+
# GitHub Trending Reporter
22

33
自动获取 GitHub Trending 数据,通过 LLM 进行智能分析,并生成可视化报告网站。
44

5-
## 🌐 在线访问
5+
## 在线访问
66

77
**网站地址**: https://wayyoungboy.github.io/github-trending-reporter/
88

9-
## 功能特点
9+
## 功能特点
1010

11-
- 🔍 **自动爬取** - 每日自动获取 GitHub Trending 热门项目
12-
- 🤖 **AI 分析** - 使用 LLM 对项目进行深度分析和趋势洞察
13-
- 📊 **可视化展示** - 使用 Docusaurus 生成美观的报告网站
14-
- **定时运行** - 通过 GitHub Actions 实现全自动化
11+
- **自动爬取** - 每日自动获取 GitHub Trending 热门项目
12+
- **AI 分析** - 使用 LLM 对项目进行深度分析和趋势洞察
13+
- **可视化展示** - 使用 Docusaurus 生成美观的报告网站
14+
- **定时运行** - 通过 GitHub Actions 实现全自动化
1515

16-
## 📁 项目结构
16+
## 项目结构
1717

1818
```
1919
github-trending-reporter/
@@ -26,13 +26,14 @@ github-trending-reporter/
2626
├── main.py # 主程序
2727
├── trending_scraper.py # 爬虫模块
2828
├── llm_analyzer.py # LLM 分析模块
29+
├── data_pusher.py # 数据推送模块
2930
├── config.py # 配置文件
3031
├── docusaurus.config.js # Docusaurus 配置
3132
├── package.json # Node.js 依赖
3233
└── requirements.txt # Python 依赖
3334
```
3435

35-
## 🚀 快速开始
36+
## 快速开始
3637

3738
### 本地运行(仅生成报告)
3839

@@ -58,7 +59,7 @@ npm install
5859
npm start
5960
```
6061

61-
## ⚙️ 配置
62+
## 配置
6263

6364
### 环境变量
6465

@@ -67,7 +68,8 @@ npm start
6768
| `LLM_API_KEY` | LLM API 密钥 |
6869
| `LLM_BASE_URL` | LLM API 地址 |
6970
| `LLM_MODEL` | 模型名称 |
70-
| `GITHUB_API_TOKEN` | GitHub API Token |
71+
| `GITHUB_API_TOKEN` | GitHub API Token(用于爬取详细信息) |
72+
| `GITHUB_TOKEN` | GitHub Token(用于推送数据) |
7173

7274
### GitHub Actions Secrets
7375

@@ -77,18 +79,34 @@ npm start
7779
- `LLM_MODEL`
7880
- `GITHUB_API_TOKEN`
7981

80-
## 🔄 自动化流程
82+
## 自动化流程
8183

82-
1. **定时触发** - 每天 UTC 00:00 自动运行
83-
2. **生成报告** - 爬取数据 → LLM 分析 → 生成 Markdown
84-
3. **提交更新** - 自动提交报告到仓库
85-
4. **部署网站** - 自动构建并部署到 GitHub Pages
84+
1. **定时触发** - 每天自动运行
85+
2. **数据采集** - 爬取 GitHub Trending 页面
86+
3. **API 增强** - 通过 GitHub API 获取详细信息
87+
4. **LLM 分析** - AI 深度分析项目
88+
5. **生成报告** - 输出 Markdown 格式报告
89+
6. **部署网站** - 自动构建并部署到 GitHub Pages
8690

87-
## 🔗 相关链接
91+
## 命令行参数
92+
93+
```bash
94+
python main.py [OPTIONS]
95+
96+
Options:
97+
-l, --language TEXT 按编程语言筛选 (如 python, javascript)
98+
-s, --since TEXT 时间范围: daily, weekly, monthly (默认: daily)
99+
--no-push 不推送到 GitHub 仓库
100+
--local 保存到本地文件
101+
--date TEXT 指定日期 (格式: YYYY-MM-DD)
102+
--no-detailed 跳过项目深度分析
103+
```
104+
105+
## 相关链接
88106

89107
- [GitHub Trending](https://github.com/trending)
90108
- [Docusaurus](https://docusaurus.io/)
91109

92110
---
93111

94-
Built with ❤️ using Python + Docusaurus
112+
Built with Python + Docusaurus

data_pusher.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def push_report(self, content: str, date_str: str) -> bool:
6666
True if successful
6767
"""
6868
file_path = self._get_file_path(date_str, "report")
69-
commit_message = f"📈 Add trending report for {date_str}"
69+
commit_message = f"Add trending report for {date_str}"
7070

7171
return self._create_or_update_file(file_path, content, commit_message)
7272

@@ -92,7 +92,7 @@ def push_raw_data(self, repos: List[Dict], date_str: str) -> bool:
9292
}
9393

9494
content = json.dumps(data, indent=2, ensure_ascii=False)
95-
commit_message = f"📊 Add raw data for {date_str}"
95+
commit_message = f"Add raw data for {date_str}"
9696

9797
return self._create_or_update_file(file_path, content, commit_message)
9898

@@ -164,15 +164,15 @@ def update_readme(self, date_str: str) -> bool:
164164
Returns:
165165
True if successful
166166
"""
167-
readme_content = f"""# 📈 GitHub Trending Reporter Data
167+
readme_content = f"""# GitHub Trending Reporter Data
168168
169169
This repository stores daily GitHub trending data and AI-generated analysis reports.
170170
171-
## 📅 Latest Report
171+
## Latest Report
172172
173-
📄 **[{date_str}](reports/{date_str[:4]}/{date_str[5:7]}/{date_str}.md)**
173+
**[{date_str}](reports/{date_str[:4]}/{date_str[5:7]}/{date_str}.md)**
174174
175-
## 📁 Repository Structure
175+
## Repository Structure
176176
177177
```
178178
├── reports/ # Markdown reports with AI analysis
@@ -186,12 +186,12 @@ def update_readme(self, date_str: str) -> bool:
186186
└── README.md
187187
```
188188
189-
## 🔗 Links
189+
## Links
190190
191191
- [GitHub Trending](https://github.com/trending)
192192
- [Source Code](https://github.com/{self.repo_owner}/github-trending-reporter)
193193
194-
## 📊 Data Format
194+
## Data Format
195195
196196
Each JSON file contains:
197197
- `date`: Report date
@@ -204,7 +204,7 @@ def update_readme(self, date_str: str) -> bool:
204204
*This data is automatically updated daily by GitHub Actions.*
205205
"""
206206

207-
return self._create_or_update_file("README.md", readme_content, f"📝 Update README for {date_str}")
207+
return self._create_or_update_file("README.md", readme_content, f"Update README for {date_str}")
208208

209209

210210
def push_data(repos: List[Dict], report: str, date_str: str) -> Dict[str, bool]:

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {themes as prismThemes} from 'prism-react-renderer';
55
const config = {
66
title: 'GitHub Trending Reporter',
77
tagline: '每日 GitHub 热门项目追踪与 AI 分析',
8-
favicon: 'img/favicon.ico',
8+
favicon: 'img/logo.svg',
99

1010
url: 'https://wayyoungboy.github.io',
1111
baseUrl: '/github-trending-reporter/',

llm_analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def generate_daily_report(self, repos: List[Dict], date_str: str, detailed_analy
365365
Complete markdown report with Docusaurus frontmatter
366366
"""
367367
# 获取热点总结
368-
print("🤖 Generating trend analysis...")
368+
print("Generating trend analysis...")
369369
trend_analysis = self.analyze_trends(repos)
370370

371371
# 解析热点总结
@@ -424,14 +424,14 @@ def generate_daily_report(self, repos: List[Dict], date_str: str, detailed_analy
424424
top_repos = sorted(repos, key=lambda x: x.get('stars_today', 0), reverse=True)
425425

426426
for i, repo in enumerate(top_repos, 1):
427-
print(f"🔍 Analyzing project {i}/{len(top_repos)}: {repo.get('full_name')}...")
427+
print(f" Analyzing project {i}/{len(top_repos)}: {repo.get('full_name')}...")
428428

429429
try:
430430
detailed = self.analyze_single_repo_detailed(repo, i)
431431
report_parts.append(detailed)
432432
report_parts.append("\n")
433433
except Exception as e:
434-
print(f" ⚠️ Error analyzing {repo.get('full_name')}: {e}")
434+
print(f" [WARN] Error analyzing {repo.get('full_name')}: {e}")
435435
# 生成简化版本
436436
report_parts.append(self._generate_fallback_analysis(repo, i))
437437
report_parts.append("\n---\n")

main.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,66 +43,66 @@ def run_report(
4343
if date_str is None:
4444
date_str = datetime.now().strftime("%Y-%m-%d")
4545

46-
print(f"🚀 Starting GitHub Trending Report for {date_str}")
47-
print(f" Language filter: {language or 'All'}")
48-
print(f" Time range: {since}")
49-
print(f" Analysis type: {analysis_type}")
50-
print(f" Detailed analysis: {'Yes (Top 5 projects)' if detailed_analysis else 'No'}")
46+
print(f"[START] GitHub Trending Report for {date_str}")
47+
print(f" Language filter: {language or 'All'}")
48+
print(f" Time range: {since}")
49+
print(f" Analysis type: {analysis_type}")
50+
print(f" Detailed analysis: {'Yes' if detailed_analysis else 'No'}")
5151
print()
5252

5353
# Step 1: Fetch trending repositories
54-
print("📥 Fetching trending repositories...")
54+
print("[1/4] Fetching trending repositories...")
5555
try:
5656
repos = fetch_trending(language=language, since=since)
57-
print(f" Found {len(repos)} repositories")
57+
print(f" Found {len(repos)} repositories")
5858
except Exception as e:
59-
print(f"❌ Error fetching trending data: {e}")
59+
print(f"[ERROR] Fetching trending data: {e}")
6060
return False
6161

6262
if not repos:
63-
print("⚠️ No repositories found")
63+
print("[WARN] No repositories found")
6464
return False
6565

6666
# Step 2: Analyze with LLM
67-
print("🤖 Analyzing with LLM...")
67+
print("[2/4] Analyzing with LLM...")
6868
try:
6969
analyzer = LLMAnalyzer()
7070
report = analyzer.generate_daily_report(repos, date_str, detailed_analysis=detailed_analysis)
71-
print(" Analysis complete")
71+
print(" Analysis complete")
7272
except Exception as e:
73-
print(f"❌ Error during LLM analysis: {e}")
73+
print(f"[ERROR] LLM analysis: {e}")
7474
# Generate basic report without LLM analysis
7575
report = generate_basic_report(repos, date_str)
76-
print(" Generated basic report without LLM analysis")
76+
print(" Generated basic report without LLM analysis")
7777

7878
# Step 3: Save locally if requested
7979
if output_local:
80-
print("💾 Saving locally...")
80+
print("[3/4] Saving locally...")
8181
try:
8282
save_local(repos, report, date_str)
83-
print(" Saved to local files")
83+
print(" Saved to local files")
8484
except Exception as e:
85-
print(f"⚠️ Error saving locally: {e}")
85+
print(f"[WARN] Saving locally: {e}")
8686

8787
# Step 4: Push to repository if requested
8888
if push_to_repo:
89-
print("📤 Pushing to repository...")
89+
print("[4/4] Pushing to repository...")
9090
try:
9191
pusher = DataPusher()
9292
results = pusher.push_all(repos, report, date_str)
9393
pusher.update_readme(date_str)
9494

9595
if results["raw_data"] and results["report"]:
96-
print(" Successfully pushed to repository")
96+
print(" Successfully pushed to repository")
9797
else:
98-
print("⚠️ Some files failed to push")
98+
print("[WARN] Some files failed to push")
9999
return False
100100
except Exception as e:
101-
print(f"❌ Error pushing to repository: {e}")
101+
print(f"[ERROR] Pushing to repository: {e}")
102102
return False
103103

104104
print()
105-
print(" Report generation complete!")
105+
print("[DONE] Report generation complete!")
106106
return True
107107

108108

0 commit comments

Comments
 (0)