references.md 3.53 KB

YouTube 爬虫参考资源汇总

官方文档

YouTube Data API v3

GitHub 参考项目

推荐项目

项目 描述 Star数
yt-dlp/yt-dlp 最活跃的 YouTube 下载工具,支持 trending 提取 100k+
pytube/pytube 轻量级 YouTube 下载库 13k+
mitchelljy/Trending-YouTube-Scraper 多地区 trending 数据爬取,使用 YouTube Data API 350+
jecordei/youtube-trending-videos-scraper YouTube trending 页面爬虫 26+
gpsyrou/tube-virality 多国家 trending 视频分析项目 28+
nubilfi/restful-trends RESTful API 获取 Google/TikTok/YouTube/Twitter Trends -
Simple-Python-Scrapy-Scrapers/youtube-scrapy-scraper Scrapy 框架专业爬虫 500+
Y3l4n/Trending-Youtube-Scraper 多地区 trending 爬虫 200+

学习资源

技术文章

API 使用

爬虫技术

代码片段

API 调用示例

# 获取 US 地区热门视频
curl "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&chart=mostPopular&regionCode=US&maxResults=50&key=YOUR_API_KEY"

yt-dlp 命令行

# 提取 trending 信息
yt-dlp --flat-playlist --playlistend 50 \
       --print '%(title)s|%(uploader)s|%(view_count)s|%(id)s' \
       "https://www.youtube.com/feed/trending"

许可证说明

  • YouTube Data API: 受 Google 服务条款约束
  • yt-dlp: The Unlicense (公有领域)
  • Scrapy 项目: BSD 3-Clause
  • pytube: MIT License

注意事项

  1. API 配额: YouTube Data API 每日 10,000 units,mostPopular 请求仅消耗 1 unit
  2. 服务条款: YouTube 禁止未经授权的爬虫,生产环境建议使用官方 API
  3. yt-dlp 合法性: 在某些司法管辖区使用可能受限,请遵守当地法律