193d2b375d
- kb-zhihu-metadata: 新增 zhihu_article_crawler.py 支持爬取知乎专栏文章 - kb-zhihu-content: 添加 article-from-media 类型支持从 MediaCrawler 数据读取 - 更新 SKILL.md 文档说明新功能
2.4 KiB
2.4 KiB
KB Zhihu Content Skill
kb-zhihu-content - Download Zhihu videos and extract content.
Features
- Video download using yt-dlp
- Subtitle extraction (returns no subtitle, triggers Whisper)
- Read article content from MediaCrawler data (NEW!)
- Supports
ZHIHU_COOKIEenvironment variable
Environment Variables
| Variable | Required | Description |
|---|---|---|
ZHIHU_COOKIE |
No | 知乎登录 Cookie (for member-only videos) |
Commands
# Download video
python zhihu_content.py --id "12345678" --type video --output "/path/to/downloads/"
# Extract subtitle (returns no subtitle, triggers Whisper)
python zhihu_content.py --id "12345678" --type subtitle --output "/path/to/subtitles/"
# 从 MediaCrawler 读取文章内容 (⚡ NEW!)
python zhihu_content.py --type article-from-media --input "~/work/MediaCrawler/data/zhihu/json/detail_contents_2026-02-27.json" --output "~/work/knowledge-base/data/zhihu/"
MediaCrawler 数据读取
新功能:从 MediaCrawler 爬取的数据中提取知乎文章内容
使用方法
# 从 MediaCrawler JSON 文件读取文章内容
python zhihu_content.py --type article-from-media \
--input "~/work/MediaCrawler/data/zhihu/json/detail_contents_2026-02-27.json" \
--output "~/work/knowledge-base/data/zhihu/"
# 查找最新的爬取数据
python zhihu_content.py --type article-from-media \
--output "~/work/knowledge-base/data/zhihu/"
参数说明
| 参数 | 说明 |
|---|---|
--type article-from-media |
从 MediaCrawler 数据读取 |
--input |
MediaCrawler 输出文件路径(可选,不指定则自动查找最新) |
--output |
输出目录 |
输出格式
{
"success": true,
"type": "article",
"filename": "zhihu_article_如何高效的爬取微信公众号.md",
"filepath": "/home/xxx/work/knowledge-base/data/zhihu/zhihu_article_如何高效的爬取微信公众号.md",
"message": "文章内容已导出"
}
原有功能
Video Download
Video download uses yt-dlp:
- Parses
ZHIHU_COOKIEenvironment variable (optional) - Creates temporary Netscape-format cookie file
- Runs
yt-dlp -f best -o <output> <url> - Cleans up temporary file
Note: 知乎视频通常没有官方字幕,将自动触发 Whisper 语音识别
Installation
# Already included in kb-skills repo
# Ensure yt-dlp is installed
pip install yt-dlp aiohttp