
Wechat Channels Ai Feed
- 215 installs
- 316 repo stars
- Updated August 4, 2026
- redfox-data/redfox-community
Helps with ai & agent building tasks during AI-assisted development.
About
wechat-channels-ai-feed is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- wechat-channels-ai-feed
- AI & Agent Building
- AI-coding skill
Wechat Channels Ai Feed by the numbers
- 215 all-time installs (skills.sh)
- +21 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #2,778 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/redfox-data/redfox-community --skill wechat-channels-ai-feedAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 215 |
|---|---|
| repo stars | ★ 316 |
| Last updated | August 4, 2026 |
| Repository | redfox-data/redfox-community ↗ |
What it does
Helps with ai & agent building tasks during AI-assisted development.
Files
AI视频号信息源
每日自动扫描视频号 AI 相关作品,按互动量(点赞/分享/评论)筛选最火内容,智能聚类后生成精美 HTML 日报。
---
能力概述
- 爆款发现:按关键词搜索视频号 AI 作品,按互动量筛选最火内容
- 智能聚类:自动从当天内容中发现话题方向,每天的分类由内容决定
- 终端表格:分类 + 标题 + 作者 + 点赞/分享/评论数,一目了然
- 可视化日报:深色主题 HTML(视频号橙色风格),封面图、互动数据、日期导航
- 一键订阅:
--subscribe开启每日自动产出,日报自动攒在本地
🔔 受视频号平台规则限制,无法提供作品链接,您可复制作品标题前往视频号搜索查看。
---
使用方式
# 生成今日爆款日报(默认关键词:AI)
python3 "$SKILL_PATH/scripts/fetch_sph_ai.py"
# 自定义关键词
python3 "$SKILL_PATH/scripts/fetch_sph_ai.py" --keyword "ChatGPT"
# 查看历史某天
python3 "$SKILL_PATH/scripts/fetch_sph_ai.py" --date 2026-06-09
# 订阅 / 取消订阅
python3 "$SKILL_PATH/scripts/fetch_sph_ai.py" --subscribe
python3 "$SKILL_PATH/scripts/fetch_sph_ai.py" --unsubscribe生成的 HTML 日报保存在 ~/Downloads/QoderReports/,自动浏览器打开。终端同步输出分类作品表格。
---
🔑 鉴权
获取 API Key
前往 redfox.hk/settings/api-keys 注册获取个人 API Key。
配置 API Key
| 方式 | 命令 |
|---|---|
| 环境变量(推荐) | export REDFOX_API_KEY=ak_你的密钥 |
| 写入 shell 配置 | echo 'export REDFOX_API_KEY=ak_你的密钥' >> ~/.zshrc && source ~/.zshrc |
脚本缺失环境变量时会明确报错并提供配置指引,不会静默失败。
---
参数说明
| 参数 | 说明 | 默认值 |
|---|---|---|
--keyword | 搜索关键词 | AI |
--page-size | 每页条数 | 200 |
--date | 指定日期 YYYY-MM-DD | 今天 |
--output-dir | 输出目录 | ~/Downloads/QoderReports |
--subscribe | 安装每日定时任务 (16:00) | — |
--unsubscribe | 卸载定时任务 | — |
--no-open | 不自动打开浏览器 | — |
---
依赖
pip3 install requests---
常见问题
Q:日报里的分类是怎么来的? A:完全由当天内容决定。从作品的 type/topic 标签中自动识别聚类,每天的热点方向不同。
Q:怎么看到更多作品? A:用 --page-size 200 增大单次查询数量。
Q:为什么没有作品链接? A:受视频号平台规则限制,无法提供作品链接供跳转,您可复制标题前往视频号搜索查看。
Q:订阅后日报存在哪? A:默认 ~/Downloads/QoderReports/,文件名格式 视频号AI日报_2026-06-10.html。
Q:没有 API Key 怎么办? A:前往 redfox.hk 注册获取,然后执行 export REDFOX_API_KEY=ak_你的密钥。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI视频号信息源 - {{DATE}}</title>
<!-- Fonts: Archivo Black (display) + Space Grotesk (body) -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Space+Grotesk:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
/* ═══════════════════════════════════════════════
CSS CUSTOM PROPERTIES — WECHAT CHANNELS ORANGE
═══════════════════════════════════════════════ */
:root {
--bg-primary: #0f0f0f;
--bg-secondary: #1a1a1a;
--bg-card: #1e1e1e;
--bg-card-hover: #252525;
--text-primary: #f0ece6;
--text-secondary: #9a9590;
--text-muted: #666;
--accent: #FA9D3B;
--accent-light: #E0861F;
--accent-glow: rgba(250, 157, 59, 0.15);
--accent-border: rgba(250, 157, 59, 0.3);
--border: rgba(255, 255, 255, 0.06);
--font-display: 'Archivo Black', Impact, sans-serif;
--font-body: 'Space Grotesk', -apple-system, sans-serif;
--title-size: clamp(1.8rem, 4vw, 3.5rem);
--h2-size: clamp(1.2rem, 2.5vw, 1.8rem);
--h3-size: clamp(1rem, 1.8vw, 1.3rem);
--body-size: clamp(0.8rem, 1.2vw, 0.95rem);
--small-size: clamp(0.7rem, 0.9vw, 0.8rem);
--radius: 12px;
--radius-sm: 8px;
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}
/* ═══════════════════════════════════════════════
RESET & BASE
═══════════════════════════════════════════════ */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
body {
font-family: var(--font-body);
font-size: var(--body-size);
background: var(--bg-primary);
color: var(--text-primary);
line-height: 1.6;
min-height: 100vh;
padding: clamp(1rem, 3vw, 3rem);
}
/* ═══════════════════════════════════════════════
HEADER — DATE PROMINENT
═══════════════════════════════════════════════ */
.report-header {
text-align: center;
padding: clamp(2rem, 5vw, 4rem) 0 clamp(1rem, 2vw, 1.5rem);
max-width: 900px;
margin: 0 auto;
}
.report-header h1 {
font-family: var(--font-display);
font-size: var(--title-size);
color: var(--accent);
letter-spacing: -0.02em;
margin-bottom: 0.3rem;
}
.report-header .subtitle {
font-size: clamp(0.9rem, 1.5vw, 1.1rem);
color: var(--text-secondary);
font-weight: 300;
margin-bottom: 1.2rem;
}
/* 大日期显示 */
.date-display {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
margin: 1.2rem 0;
}
.date-display .date-text {
font-family: var(--font-display);
font-size: clamp(1.4rem, 3vw, 2.4rem);
color: var(--text-primary);
letter-spacing: 0.02em;
}
.date-nav-btn {
background: var(--bg-secondary);
border: 1px solid var(--border);
color: var(--text-secondary);
width: 36px;
height: 36px;
border-radius: 50%;
cursor: pointer;
font-size: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.date-nav-btn:hover {
border-color: var(--accent-border);
color: var(--accent);
background: var(--accent-glow);
}
/* PLATFORM NOTICE */
.platform-notice {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.9rem 1.5rem;
margin: 0 auto 2rem;
max-width: 700px;
background: linear-gradient(135deg, rgba(250,157,59,0.08), rgba(250,157,59,0.04));
border: 1px solid var(--accent-border);
border-radius: var(--radius);
color: var(--accent);
font-size: var(--body-size);
font-weight: 500;
line-height: 1.7;
text-align: center;
}
.platform-notice-icon {
font-size: 1.3rem;
flex-shrink: 0;
}
@media (max-width: 600px) {
.platform-notice {
flex-direction: column;
gap: 0.3rem;
padding: 0.8rem 1rem;
}
}
/* ═══════════════════════════════════════════════
STATS BAR
═══════════════════════════════════════════════ */
.stats-bar {
display: flex;
justify-content: center;
gap: clamp(1.5rem, 4vw, 3rem);
padding: clamp(1rem, 2vw, 1.5rem) clamp(1rem, 3vw, 2rem);
background: var(--bg-secondary);
border-radius: var(--radius);
border: 1px solid var(--border);
max-width: 700px;
margin: clamp(0.5rem, 1vw, 1rem) auto clamp(2rem, 4vw, 3rem);
flex-wrap: wrap;
}
.stat-item {
text-align: center;
min-width: 80px;
}
.stat-value {
font-family: var(--font-display);
font-size: var(--h2-size);
color: var(--accent);
line-height: 1.2;
}
.stat-label {
font-size: var(--small-size);
color: var(--text-secondary);
margin-top: 0.2rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
/* ═══════════════════════════════════════════════
CATEGORY CARDS GRID
═══════════════════════════════════════════════ */
.cards-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
gap: clamp(1rem, 2vw, 1.5rem);
max-width: 1200px;
margin: 0 auto;
}
.category-card {
background: var(--bg-card);
border-radius: var(--radius);
border: 1px solid var(--border);
overflow: hidden;
transition: transform 0.3s var(--ease-out-expo), border-color 0.3s ease;
}
.category-card:hover {
transform: translateY(-2px);
border-color: var(--accent-border);
}
.category-card.hidden {
display: none;
}
.card-header {
display: flex;
align-items: center;
gap: 0.8rem;
padding: clamp(1rem, 2vw, 1.3rem) clamp(1rem, 2vw, 1.5rem);
background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
}
.card-number {
font-family: var(--font-display);
font-size: var(--h2-size);
color: rgba(0, 0, 0, 0.3);
line-height: 1;
}
.card-category {
flex: 1;
font-family: var(--font-body);
font-size: var(--h3-size);
font-weight: 700;
color: #fff;
}
.card-count {
font-size: var(--small-size);
color: rgba(255, 255, 255, 0.8);
font-weight: 500;
background: rgba(0, 0, 0, 0.2);
padding: 0.2rem 0.6rem;
border-radius: 10px;
}
.card-body {
padding: clamp(0.8rem, 1.5vw, 1.2rem) clamp(1rem, 2vw, 1.5rem);
max-height: 520px;
overflow-y: auto;
}
.card-body::-webkit-scrollbar { width: 4px; }
.card-body::-webkit-scrollbar-track { background: transparent; }
.card-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.card-body::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
/* ═══════════════════════════════════════════════
ARTICLE ITEMS
═══════════════════════════════════════════════ */
.article-item {
padding: 0.7rem 0;
border-bottom: 1px solid var(--border);
display: flex;
gap: 0.8rem;
align-items: flex-start;
}
.article-item:last-child {
border-bottom: none;
padding-bottom: 0;
}
.article-cover {
width: 72px;
height: 72px;
border-radius: var(--radius-sm);
object-fit: cover;
flex-shrink: 0;
background: var(--bg-secondary);
}
.article-info {
flex: 1;
min-width: 0;
}
.article-title {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
color: var(--text-primary);
text-decoration: none;
font-size: var(--body-size);
font-weight: 500;
line-height: 1.5;
transition: color 0.2s ease;
}
.article-title:hover {
color: var(--accent);
}
.article-meta {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 0.3rem;
font-size: var(--small-size);
color: var(--text-muted);
flex-wrap: wrap;
gap: 0.3rem;
}
.author {
color: var(--text-secondary);
}
.metrics {
display: flex;
gap: 0.8rem;
}
.metric {
white-space: nowrap;
}
/* ═══════════════════════════════════════════════
FOOTER
═══════════════════════════════════════════════ */
.report-footer {
text-align: center;
padding: clamp(2rem, 4vw, 3rem) 0 1rem;
color: var(--text-muted);
font-size: var(--small-size);
}
.report-footer .powered {
margin-top: 0.5rem;
color: var(--text-secondary);
}
/* ═══════════════════════════════════════════════
ANIMATIONS
═══════════════════════════════════════════════ */
.reveal {
opacity: 0;
transform: translateY(20px);
transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
}
.reveal.visible {
opacity: 1;
transform: translateY(0);
}
.category-card:nth-child(1) { transition-delay: 0.05s; }
.category-card:nth-child(2) { transition-delay: 0.1s; }
.category-card:nth-child(3) { transition-delay: 0.15s; }
.category-card:nth-child(4) { transition-delay: 0.2s; }
.category-card:nth-child(5) { transition-delay: 0.25s; }
.category-card:nth-child(6) { transition-delay: 0.3s; }
.category-card:nth-child(7) { transition-delay: 0.35s; }
.category-card:nth-child(8) { transition-delay: 0.4s; }
/* ═══════════════════════════════════════════════
RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 600px) {
.stats-bar {
gap: 1rem;
}
.stat-item {
min-width: 60px;
}
.cards-grid {
grid-template-columns: 1fr;
}
.date-display .date-text {
font-size: 1.3rem;
}
.article-cover {
width: 56px;
height: 56px;
}
}
@media (prefers-reduced-motion: reduce) {
.reveal {
opacity: 1;
transform: none;
transition: none;
}
}
</style>
</head>
<body>
<!-- HEADER -->
<header class="report-header">
<h1>AI视频号信息源</h1>
<p class="subtitle">每日 AI 热门作品 · 互动量靠前的爆款一网打尽</p>
<!-- 大日期 + 前后切换 -->
<div class="date-display">
<button class="date-nav-btn" id="prevDay" title="前一天">←</button>
<span class="date-text">{{DATE_CN}}</span>
<button class="date-nav-btn" id="nextDay" title="后一天">→</button>
</div>
</header>
<!-- STATS BAR -->
<div class="stats-bar">
<div class="stat-item">
<div class="stat-value">{{TOPIC_COUNT}}</div>
<div class="stat-label">分类</div>
</div>
<div class="stat-item">
<div class="stat-value">{{TOTAL_COUNT}}</div>
<div class="stat-label">作品</div>
</div>
<div class="stat-item">
<div class="stat-value">{{AVG_LIKES}}</div>
<div class="stat-label">平均点赞</div>
</div>
<div class="stat-item">
<div class="stat-value">{{TOTAL_SHARES}}</div>
<div class="stat-label">总分享</div>
</div>
</div>
<!-- PLATFORM NOTICE -->
<div class="platform-notice">
<span class="platform-notice-icon">🔔</span>
<span>受视频号平台规则限制,无法提供作品链接供跳转,您可复制作品标题前往视频号搜索查看,感谢理解 🙇♀️</span>
</div>
<!-- CATEGORY CARDS -->
<div class="cards-grid" id="cardsGrid">
{{CATEGORY_CARDS}}
</div>
<!-- FOOTER -->
<footer class="report-footer">
<p>Generated at {{TIMESTAMP}}</p>
<p class="powered">Powered by AI视频号信息源 Skill</p>
</footer>
<!-- SCRIPTS -->
<script>
(function() {
// ── Scroll reveal animation ──
var observer = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' });
document.querySelectorAll('.reveal').forEach(function(el) {
observer.observe(el);
});
// ── Date navigation ──
var currentDate = '{{DATE}}';
function navigateDate(offset) {
var parts = currentDate.split('-');
var d = new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, parseInt(parts[2]));
d.setDate(d.getDate() + offset);
var y = d.getFullYear();
var m = String(d.getMonth() + 1).padStart(2, '0');
var day = String(d.getDate()).padStart(2, '0');
var newDate = y + '-' + m + '-' + day;
var newFile = '视频号AI日报_' + newDate + '.html';
window.location.href = newFile;
}
document.getElementById('prevDay').addEventListener('click', function() {
navigateDate(-1);
});
document.getElementById('nextDay').addEventListener('click', function() {
navigateDate(1);
});
})();
</script>
</body>
</html>
AI WeChat Video Feed / wechat-channels-ai-feed
---
Overview
Daily auto-scan of AI-related WeChat Video (视频号) content, filtering the hottest posts by engagement (likes / shares / comments), intelligently clustering them into topics, and generating a beautifully styled HTML daily report with cover images, metrics, and subscription support. Your one-stop solution to stay on top of the AI scene on WeChat Video.
Core Value
- Discover the hottest AI posts on WeChat Video daily, saving time from manual browsing
- Auto-clustering by content topics gives you a clear picture of what's trending in AI today
- Stunning dark-themed visual daily report (WeChat Channels orange style) with cover images and engagement metrics at a glance
- Daily auto-push with archived reports — browse history anytime
🔔 Due to WeChat Video platform restrictions, direct links to posts are not available. You can copy the title and search on WeChat Video.
Who It's For
- 📱 Content operators — track AI trend styles and get creative inspiration
- 🎬 AI creators — learn from trending content and understand platform dynamics
- 📊 Industry observers — monitor AI content trends for market insights
---
Features
Core Capabilities
- Search WeChat Video AI posts by keywords, filtered by engagement metrics
- Auto-detect topic directions from content tags and intelligently cluster into category cards
- Terminal table display: category + title + author + likes / shares / comments
- Generate a dark-themed visual daily report (WeChat Channels orange style) with cover images, metrics, and date navigation
---
API Key Acquisition & Security
- This skill requires the environment variable:
REDFOX_API_KEY. REDFOX_API_KEYis provided by RedFoxHub (https://redfox.hk).- Visit RedFoxHub to register and get your
REDFOX_API_KEY. - Configure the
REDFOX_API_KEYenvironment variable on your device before using this skill. - Before providing your key, verify the source, scope, validity period, and whether it supports reset/revocation.
- Never hardcode or expose your key in code, prompts, logs, or output files.
---
Usage
Simply describe your need in natural language — no commands to memorize.
Quick Reference
| Intent | Example | Result |
|---|---|---|
| View today's AI Video report | "Show me today's WeChat Video AI report" | Fetches the hottest AI posts and generates a clustered visual report |
| Search by custom keyword | "Search WeChat Video for ChatGPT content" | Filters by your keyword and generates a tailored report |
| Look up a past date | "Show me WeChat Video AI data from June 5th" | Retrieves the historical daily report for that date |
---
Use Cases
| Scenario | Role | Example Query | Benefit |
|---|---|---|---|
| Daily AI trend tracking | Content operator | "Today's AI WeChat Video report" | Automatically get daily hot content, no manual browsing |
| Competitor content analysis | AI creator | "Search WeChat Video for trending AI short dramas" | Understand trending styles and performance data |
| Hot topic review | Industry analyst | "Show me WeChat Video AI trends from June 1st" | Review historical data and analyze topic evolution |
AI视频号信息源 / wechat-channels-ai-feed
---
简介
每日自动扫描视频号 AI 相关作品,按互动量筛选最火内容,智能聚类生成精美可视化日报,支持封面图、数据指标和每日订阅。帮你一站式掌握视频号 AI 赛道每日爆款,不错过任何一个热点。
核心价值
- 每日自动发现视频号最火的 AI 作品,省去手动刷视频号找素材的时间
- 按内容主题自动聚类,一眼看清今天 AI 圈在聊什么
- 精美深色主题可视化日报(视频号橙色风格),封面图 + 互动数据一目了然
- 支持每日自动推送,日报自动积攒,随时翻阅历史
🔔 受视频号平台规则限制,日报中不提供作品链接,您可复制标题前往视频号搜索查看。
适用对象
- 📱 内容运营 — 追踪 AI 赛道爆款风格,获取创作灵感
- 🎬 AI 创作者 — 了解同行热门内容,把握平台风向
- 📊 行业观察者 — 监控 AI 内容趋势,辅助市场判断
---
功能特性
核心功能
- 按关键词搜索视频号 AI 作品,按互动量筛选最火内容
- 自动从内容标签中识别话题方向,智能聚类生成分类卡片
- 终端表格展示分类 + 标题 + 作者 + 点赞/分享/评论
- 生成深色主题可视化日报(视频号橙色风格),含封面图、互动数据、日期导航
---
密钥获取与安全说明
- 本技能需要使用环境变量:
REDFOX_API_KEY。 REDFOX_API_KEY由 红狐 hub (https://redfox.hk)提供。- 请前往 红狐 hub 注册账号,获取
REDFOX_API_KEY。 - 配置设备环境变量
REDFOX_API_KEY后使用本技能。 - 在提供密钥前,请先确认密钥来源、可用范围、有效期及是否支持重置/撤销。
- 禁止在代码、提示词、日志或输出文件中硬编码/明文暴露密钥。
---
使用指南
直接用自然语言描述需求,无需记忆命令。
常用说法速查
| 意图 | 示例话术 | 效果 |
|---|---|---|
| 查看今日 AI 视频号日报 | 「看看视频号 AI 热点」「视频号 AI 日报」 | 拉取当日最火 AI 作品,聚类生成可视化日报 |
| 指定关键词搜索 | 「搜一下视频号 ChatGPT 相关内容」 | 按自定义关键词筛选,生成对应日报 |
| 回溯历史某天 | 「看一下 6 月 5 号的视频号 AI 数据」 | 拉取指定日期的历史日报 |
---
使用场景
| 场景 | 角色 | 示例问法 | 收益 |
|---|---|---|---|
| 每日 AI 趋势追踪 | 内容运营 | 「今天的 AI 视频号日报」 | 省去手动刷视频号,自动获取当日爆款 |
| 竞品内容分析 | AI 创作者 | 「搜一下视频号 AI 短剧的热门内容」 | 了解同行爆款风格与数据表现 |
| 热点事件复盘 | 行业分析 | 「看看 6 月 1 号的视频号 AI 趋势」 | 回溯历史数据,分析 AI 话题演变 |
#!/usr/bin/env python3
"""
AI视频号信息源 — 每日 AI 相关视频号热门内容聚合
=================================================
根据关键词搜索视频号 AI 相关作品,按互动量排序后生成 HTML 日报。
Usage:
python3 fetch_sph_ai.py
python3 fetch_sph_ai.py --keyword "ChatGPT"
python3 fetch_sph_ai.py --subscribe
"""
import argparse
import json
import os
import subprocess
import sys
import time
from collections import Counter, defaultdict
from datetime import datetime, timedelta
from pathlib import Path
try:
import requests
HAS_REQUESTS = True
except ImportError:
HAS_REQUESTS = False
# ─── 配置 ─────────────────────────────────────────────────────────────────────────
API_URL = "https://redfox.hk/story/api/parseWork/querySphAiMsgs"
ENV_KEY = "REDFOX_API_KEY"
SOURCE = "AI视频号信息源-GitHub"
DEFAULT_KEYWORD = "AI"
DEFAULT_OUTPUT_DIR = Path.home() / "Downloads" / "QoderReports"
PAGE_SIZE = 200
PLIST_LABEL = "com.qoder.wechat-channels-ai-feed"
PLIST_DIR = Path.home() / "Library" / "LaunchAgents"
# ─── 终端颜色 ──────────────────────────────────────────────────────────────────────
GREEN = "\033[92m"
YELLOW = "\033[93m"
RED = "\033[91m"
CYAN = "\033[96m"
BOLD = "\033[1m"
RESET = "\033[0m"
def info(msg):
print(f"{GREEN}[✓]{RESET} {msg}")
def warn(msg):
print(f"{YELLOW}[!]{RESET} {msg}")
def error(msg):
print(f"{RED}[✗]{RESET} {msg}")
def step(msg):
print(f"{CYAN}[→]{RESET} {msg}")
# ─── API Key 管理 ──────────────────────────────────────────────────────────────────
def get_api_key():
"""从环境变量读取 API Key,缺失时报错退出。"""
key = os.environ.get(ENV_KEY, "").strip()
if key:
return key
error(f"未检测到环境变量 {ENV_KEY}")
print(f"\n{YELLOW} 请先配置 API Key:{RESET}")
print(f" {CYAN}方式一(推荐){RESET}:export REDFOX_API_KEY=ak_你的密钥")
print(f" {CYAN}方式二{RESET}:将 export REDFOX_API_KEY=ak_你的密钥 写入 ~/.zshrc 或 ~/.bashrc")
print(f"\n 获取 API Key:{CYAN}https://www.redfox.hk/login{RESET}")
sys.exit(1)
# ─── 数据获取 ──────────────────────────────────────────────────────────────────────
def fetch_articles(session, keyword, page_size):
"""单次调用接口获取作品数据,返回实际获取的作品列表(不支持时间过滤)"""
payload = {
"keyword": keyword,
"pageNum": 1,
"pageSize": page_size,
"source": SOURCE,
}
print(f"\r {CYAN}[→]{RESET} 请求中: keyword=\"{keyword}\", pageSize={page_size}", end="", flush=True)
try:
resp = session.post(API_URL, json=payload, timeout=15)
result = resp.json()
except Exception as e:
print()
warn(f"请求失败: {e}")
return []
code = result.get("code")
if code == 3108:
warn("限频,等待 5s...")
time.sleep(5)
try:
resp = session.post(API_URL, json=payload, timeout=15)
result = resp.json()
code = result.get("code")
except Exception:
print()
return []
if code not in (200, 2000):
if code in (3106, 3107):
error(f"API Key 错误 (code {code}): {result.get('msg', '')}")
print()
return []
data = result.get("data", {})
articles = data.get("list", [])
print(f"\r {CYAN}[→]{RESET} 接口返回 {len(articles)} 篇作品 ")
return articles
# ─── 自动聚类 ──────────────────────────────────────────────────────────────────────
# 过于宽泛的标签,聚类时跳过
GENERIC_TAGS = {"#AI", "#人工智能", "#ai", "AI", "人工智能", "#科技", "#技术", "科技", "技术"}
def cluster_articles(articles):
"""基于 type / topic 标签自动聚类,大类按第二标签二次拆分"""
total = len(articles)
def _get_tags(article):
atype = (article.get("type") or "").strip()
topic = (article.get("topic") or "").strip()
raw = atype or topic or ""
tags = [t.strip().lstrip("#").strip() for t in raw.split(",") if t.strip()]
# 过滤掉泛标签
return [t for t in tags if t not in GENERIC_TAGS]
# 第一轮:按首标签聚类
topic_groups = defaultdict(list)
for article in articles:
tags = _get_tags(article)
category = tags[0] if tags else "其他"
topic_groups[category].append(article)
# 合并小组(< 2 篇归入"其他")
final_groups = {}
small_articles = []
for topic, arts in topic_groups.items():
if len(arts) >= 2:
final_groups[topic] = arts
else:
small_articles.extend(arts)
if small_articles:
final_groups.setdefault("其他", []).extend(small_articles)
# 二次拆分:超过总量 50% 的分类,按第二标签再拆分
to_split = {k: v for k, v in final_groups.items() if len(v) > total * 0.5 and k != "其他"}
for big_cat, big_arts in to_split.items():
del final_groups[big_cat]
sub_groups = defaultdict(list)
for art in big_arts:
tags = _get_tags(art)
if len(tags) >= 2:
sub_groups[tags[1]].append(art)
else:
sub_groups["其他"].append(art)
for sub_name, sub_arts in sub_groups.items():
key = sub_name if sub_name != "其他" else f"{big_cat}·其他"
final_groups[key] = sub_arts
# 二次合并(拆分后的小组 < 2 篇归入"其他")
merged = {}
small2 = []
for topic, arts in final_groups.items():
if len(arts) >= 2:
merged[topic] = arts
else:
small2.extend(arts)
if small2:
merged.setdefault("其他", []).extend(small2)
# 构建输出,按条数降序
clusters = []
for category, arts in sorted(merged.items(), key=lambda x: -len(x[1])):
sorted_arts = sorted(arts, key=lambda a: (
(a.get("likeCount") or 0) + (a.get("shareCount") or 0) + (a.get("commentCount") or 0)
), reverse=True)
clusters.append({
"category": category,
"count": len(sorted_arts),
"articles": sorted_arts,
})
return clusters
# ─── HTML 报告生成 ──────────────────────────────────────────────────────────────────
def compute_stats(articles):
"""计算统计数据"""
total = len(articles)
if total == 0:
return {"total": 0, "avg_likes": 0, "top_author": "-", "total_shares": 0}
likes = [a.get("likeCount") or 0 for a in articles]
avg_likes = sum(likes) // total if total > 0 else 0
author_counter = Counter(a.get("userName") or "未知" for a in articles)
top_author = author_counter.most_common(1)[0][0] if author_counter else "-"
total_shares = sum(a.get("shareCount") or 0 for a in articles)
return {
"total": total,
"avg_likes": avg_likes,
"top_author": top_author,
"total_shares": total_shares,
}
def format_number(n):
"""格式化数字: 1234 -> 1.2k"""
if n is None:
return "0"
if n >= 10000:
return f"{n/10000:.1f}w"
if n >= 1000:
return f"{n/1000:.1f}k"
return str(n)
def print_article_table(clusters):
"""在终端打印分类作品表格"""
print(f"\n{BOLD}{'='*78}{RESET}")
print(f"{BOLD} AI视频号信息源 · 分类作品一览{RESET}")
print(f"{BOLD}{'='*78}{RESET}\n")
for i, cluster in enumerate(clusters, 1):
category = cluster["category"]
arts = cluster["articles"]
print(f" {CYAN}{BOLD}【{category}】{RESET} "
f"{cluster['count']} 篇")
header = (f" {'序号':<4}{'标题':<36}{'作者':<14}"
f"{'点赞':>8}{'分享':>8}{'评论':>8}")
print(f" {YELLOW}{'─'*76}{RESET}")
print(f" {YELLOW}{header}{RESET}")
print(f" {YELLOW}{'─'*76}{RESET}")
for j, article in enumerate(arts, 1):
title = article.get("title", "无标题") or "无标题"
author = article.get("userName") or "-"
likes = format_number(article.get("likeCount"))
shares = format_number(article.get("shareCount"))
comments = format_number(article.get("commentCount"))
display_title = title[:34] + ".." if len(title) > 36 else title
display_author = author[:12] + ".." if len(author) > 14 else author
print(f" {j:<4}{display_title:<36}{display_author:<14}"
f"{likes:>8}{shares:>8}{comments:>8}")
print()
def generate_category_cards(clusters):
"""生成分区卡片 HTML(每个分类一个大卡片,内含竖向文章列表)"""
cards_html = ""
for i, cluster in enumerate(clusters, 1):
articles_html = ""
for article in cluster["articles"][:10]: # 每个分类只展示 top 10
title = article.get("title", "无标题") or "无标题"
author = article.get("userName") or ""
cover = article.get("coverUrl") or ""
likes = format_number(article.get("likeCount"))
shares = format_number(article.get("shareCount"))
comments = format_number(article.get("commentCount"))
cover_html = ""
if cover:
cover_html = f'<img class="article-cover" src="{cover}" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.onerror=null;this.style.background='#fff';this.src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'">'
articles_html += f'''
<div class="article-item">
{cover_html}
<div class="article-info">
<span class="article-title" title="{title}">{title}</span>
<div class="article-meta">
<span class="author">{author}</span>
<span class="metrics">
<span class="metric">👍 {likes}</span>
<span class="metric">🔁 {shares}</span>
<span class="metric">💬 {comments}</span>
</span>
</div>
</div>
</div>'''
cards_html += f'''
<div class="category-card reveal">
<div class="card-header">
<span class="card-number">{i:02d}</span>
<h3 class="card-category">{cluster["category"]}</h3>
<span class="card-count">{cluster["count"]} 篇</span>
</div>
<div class="card-body">{articles_html}
</div>
</div>'''
return cards_html
def generate_report(clusters, articles, date_str, api_key=None):
"""生成完整 HTML 报告"""
stats = compute_stats(articles)
topic_count = len(clusters)
template_path = Path(__file__).parent.parent / "assets" / "report_template.html"
if template_path.exists():
template = template_path.read_text(encoding="utf-8")
else:
warn("模板文件未找到,使用内置模板")
template = get_fallback_template()
try:
dt = datetime.strptime(date_str, "%Y-%m-%d")
weekdays = ["一", "二", "三", "四", "五", "六", "日"]
date_cn = f"{dt.year}年{dt.month}月{dt.day}日 星期{weekdays[dt.weekday()]}"
except ValueError:
date_cn = date_str
category_cards = generate_category_cards(clusters)
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
html = template
html = html.replace("{{DATE}}", date_str)
html = html.replace("{{DATE_CN}}", date_cn)
html = html.replace("{{TOTAL_COUNT}}", str(stats["total"]))
html = html.replace("{{TOPIC_COUNT}}", str(topic_count))
html = html.replace("{{TOP_AUTHOR}}", stats["top_author"])
html = html.replace("{{AVG_LIKES}}", format_number(stats["avg_likes"]))
html = html.replace("{{TOTAL_SHARES}}", format_number(stats["total_shares"]))
html = html.replace("{{CATEGORY_CARDS}}", category_cards)
html = html.replace("{{TIMESTAMP}}", timestamp)
return html
def get_fallback_template():
"""内置最小 HTML 模板(当模板文件缺失时使用)"""
return '''<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI视频号信息源 - {{DATE}}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e8e4df; padding: 2rem; }
.header { text-align: center; padding: 2rem 0; }
.header h1 { font-size: 2rem; color: #07C160; }
.header p { color: #9a9590; margin-top: 0.5rem; }
.stats { display: flex; justify-content: center; gap: 2rem; padding: 1rem; margin: 1rem 0; }
.stat-item { text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: bold; color: #07C160; }
.stat-label { font-size: 0.8rem; color: #9a9590; }
.search-bar { max-width: 500px; margin: 1.5rem auto 0; position: relative; }
.search-bar input { width: 100%; padding: 0.7rem 1.2rem 0.7rem 2.8rem; background: #1a1a1a; border: 1px solid rgba(255,255,255,0.06); border-radius: 24px; color: #f0ece6; font-size: 0.95rem; outline: none; }
.search-bar input:focus { border-color: rgba(7, 193, 96, 0.3); }
.search-bar .search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #666; font-size: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1.5rem; max-width: 1200px; margin: 2rem auto; }
.category-card { background: #2d2d2d; border-radius: 12px; overflow: hidden; }
.card-header { display: flex; align-items: center; gap: 0.8rem; padding: 1rem 1.2rem; background: linear-gradient(135deg, #07C160, #06AD56); }
.card-number { font-size: 1.5rem; font-weight: bold; color: rgba(0,0,0,0.3); }
.card-category { flex: 1; font-size: 1.1rem; font-weight: 700; color: #fff; }
.card-count { font-size: 0.8rem; color: rgba(255,255,255,0.8); background: rgba(0,0,0,0.2); padding: 0.2rem 0.6rem; border-radius: 10px; }
.card-body { padding: 0.8rem 1.2rem; max-height: 520px; overflow-y: auto; }
.article-item { padding: 0.6rem 0; border-bottom: 1px solid #3d3d3d; display: flex; gap: 0.8rem; }
.article-item:last-child { border-bottom: none; }
.article-cover { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #1a1a1a; }
.article-info { flex: 1; min-width: 0; }
.article-title { color: #e8e4df; text-decoration: none; font-size: 0.9rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-title:hover { color: #07C160; }
.article-meta { display: flex; justify-content: space-between; margin-top: 0.3rem; font-size: 0.75rem; color: #9a9590; }
.metrics { display: flex; gap: 0.8rem; }
.footer { text-align: center; padding: 2rem; color: #666; font-size: 0.8rem; }
</style>
</head>
<body>
<div class="header">
<h1>AI视频号信息源</h1>
<p>{{DATE_CN}} | 共 {{TOTAL_COUNT}} 篇热门作品</p>
</div>
<div class="stats">
<div class="stat-item"><div class="stat-value">{{TOPIC_COUNT}}</div><div class="stat-label">分类</div></div>
<div class="stat-item"><div class="stat-value">{{TOTAL_COUNT}}</div><div class="stat-label">作品</div></div>
<div class="stat-item"><div class="stat-value">{{AVG_LIKES}}</div><div class="stat-label">平均点赞</div></div>
<div class="stat-item"><div class="stat-value">{{TOTAL_SHARES}}</div><div class="stat-label">总分享</div></div>
</div>
<div class="cards">{{CATEGORY_CARDS}}</div>
<div class="footer">Generated at {{TIMESTAMP}} by AI视频号信息源 Skill</div>
</body>
</html>'''
# ─── 订阅机制 ──────────────────────────────────────────────────────────────────────
def install_subscription():
"""安装定时任务,每天自动生成日报"""
if sys.platform == "darwin":
PLIST_DIR.mkdir(parents=True, exist_ok=True)
plist_path = PLIST_DIR / f"{PLIST_LABEL}.plist"
script_path = os.path.abspath(__file__)
log_path = str(Path.home() / "Library" / "Logs" / "qoder-wechat-channels-ai-feed.log")
env_section = ""
api_key = os.environ.get(ENV_KEY, "").strip()
if api_key:
env_section = f"""
<key>EnvironmentVariables</key>
<dict>
<key>{ENV_KEY}</key>
<string>{api_key}</string>
</dict>"""
plist_content = f'''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>{PLIST_LABEL}</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python3</string>
<string>{script_path}</string>
<string>--no-open</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>16</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardOutPath</key>
<string>{log_path}</string>
<key>StandardErrorPath</key>
<string>{log_path}</string>
<key>RunAtLoad</key>
<false/>{env_section}
</dict>
</plist>'''
plist_path.write_text(plist_content, encoding="utf-8")
try:
subprocess.run(["launchctl", "load", str(plist_path)],
check=True, capture_output=True)
info("订阅成功! 每天 16:00 自动生成视频号 AI 日报")
info(f"日报目录: ~/Downloads/QoderReports/")
info(f"日志: {log_path}")
return True
except subprocess.CalledProcessError as e:
error(f"订阅安装失败: {e.stderr.decode()}")
return False
else:
script_path = os.path.abspath(__file__)
cron_line = f"0 16 * * * /usr/bin/python3 {script_path} --no-open"
try:
subprocess.run(
f'(crontab -l 2>/dev/null; echo "{cron_line}") | crontab -',
shell=True, check=True, capture_output=True
)
info("订阅成功! 每天 16:00 自动生成视频号 AI 日报 (crontab)")
info(f"日报目录: ~/Downloads/QoderReports/")
return True
except subprocess.CalledProcessError:
warn("自动配置 crontab 失败,请手动添加:")
print(f" {cron_line}")
return False
def remove_subscription():
"""卸载定时任务"""
if sys.platform == "darwin":
plist_path = PLIST_DIR / f"{PLIST_LABEL}.plist"
if not plist_path.exists():
warn("未找到订阅配置,无需取消")
return False
try:
subprocess.run(["launchctl", "unload", str(plist_path)],
check=True, capture_output=True)
except subprocess.CalledProcessError:
pass
plist_path.unlink(missing_ok=True)
info("已取消订阅,定时任务已移除")
return True
else:
script_path = os.path.abspath(__file__)
try:
subprocess.run(
f'crontab -l 2>/dev/null | grep -v "{script_path}" | crontab -',
shell=True, check=True, capture_output=True
)
info("已取消订阅,crontab 任务已移除")
return True
except subprocess.CalledProcessError:
warn("自动移除 crontab 失败,请手动执行: crontab -e")
return False
# ─── 主流程 ────────────────────────────────────────────────────────────────────────
def main():
parser = argparse.ArgumentParser(
description="AI视频号信息源 — 每日 AI 相关视频号热门内容聚合",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python3 fetch_sph_ai.py
python3 fetch_sph_ai.py --keyword "ChatGPT"
python3 fetch_sph_ai.py --start-time 2026-06-09 --end-time 2026-06-10
python3 fetch_sph_ai.py --subscribe
python3 fetch_sph_ai.py --unsubscribe
""",
)
parser.add_argument("--keyword", default=DEFAULT_KEYWORD,
help=f"搜索关键词 (默认: {DEFAULT_KEYWORD})")
parser.add_argument("--page-size", type=int, default=PAGE_SIZE,
help=f"每页条数 (默认: {PAGE_SIZE})")
parser.add_argument("--date", default=datetime.now().strftime("%Y-%m-%d"),
help="指定日期 YYYY-MM-DD (默认: 今天)")
parser.add_argument("--start-time", default=None,
help="开始时间 YYYY-MM-DD(含),不传则根据 --date 自动计算")
parser.add_argument("--end-time", default=None,
help="结束时间 YYYY-MM-DD(不含),不传则根据 --date 自动计算")
parser.add_argument("--output-dir",
help=f"输出目录 (默认: ~/Downloads/QoderReports)")
parser.add_argument("--subscribe", action="store_true",
help="安装每日定时任务 (16:00)")
parser.add_argument("--unsubscribe", action="store_true",
help="卸载定时任务")
parser.add_argument("--no-open", action="store_true",
help="不自动打开浏览器")
args = parser.parse_args()
# ── Banner ──
banner = f"""{CYAN}{BOLD}
╔══════════════════════════════════════╗
║ AI视频号信息源 · 日报生成 ║
║ 每日 AI 热门作品 · 爆款一网打尽 ║
╚══════════════════════════════════════╝{RESET}
"""
print(banner)
# ── 订阅/取消 ──
if args.subscribe:
install_subscription()
return
if args.unsubscribe:
remove_subscription()
return
# ── 检查依赖 ──
if not HAS_REQUESTS:
error("缺少 requests 库,请安装: pip3 install requests")
sys.exit(1)
# ── API Key ──
api_key = get_api_key()
# ── Session ──
session = requests.Session()
session.verify = True
session.headers.update({
"Content-Type": "application/json",
"X-API-KEY": api_key,
})
# ── 获取作品(单次接口调用)──
keyword = args.keyword.strip()
step(f"查询关键词: \"{keyword}\" (pageSize={args.page_size})")
articles = fetch_articles(session, keyword, args.page_size)
if not articles:
error("未获取到任何作品")
sys.exit(1)
info(f"获取完成: {len(articles)} 篇作品")
# ── 自动聚类 ──
step("正在自动聚类...")
clusters = cluster_articles(articles)
info(f"聚类完成: 发现 {len(clusters)} 个分类")
for c in clusters[:10]:
print(f" {c['category']}: {c['count']} 篇")
# ── 终端表格展示 ──
print_article_table(clusters)
# ── 生成报告 ──
step("生成 HTML 日报...")
html_content = generate_report(clusters, articles, args.date, api_key=api_key)
# ── 保存文件 ──
output_dir = Path(args.output_dir) if args.output_dir else DEFAULT_OUTPUT_DIR
output_dir.mkdir(parents=True, exist_ok=True)
filename = f"视频号AI日报_{args.date}.html"
output_path = output_dir / filename
output_path.write_text(html_content, encoding="utf-8")
info(f"日报已生成: {output_path}")
# ── 打开浏览器 ──
if not args.no_open:
if sys.platform == "darwin":
subprocess.run(["open", str(output_path)], check=False)
elif sys.platform == "linux":
subprocess.run(["xdg-open", str(output_path)], check=False)
info(f"浏览器已打开: {output_path}")
print(f"\n{GREEN}{BOLD}✓ 完成!{RESET}")
print(f" 文件: {output_path}")
print(f" 分类: {len(clusters)} 个")
print(f" 作品: {len(articles)} 篇")
print(f"\n {YELLOW}📢 受视频号平台规则限制,无法提供作品链接供跳转,您可复制作品标题前往视频号搜索查看,感谢理解🙇♀️🙇♀️{RESET}")
print(f"\n{CYAN}💡 需要每日下午4点自动推送最新研究数据吗?{RESET}")
if __name__ == "__main__":
main()