# YouTube 爬虫参考资源汇总 ## 官方文档 ### YouTube Data API v3 - [YouTube Data API 官方文档](https://developers.google.com/youtube/v3) - [Videos: list 端点文档](https://developers.google.com/youtube/v3/docs/videos/list) - [API 配额计算器](https://developers.google.com/youtube/v3/determine_quota_cost) - [视频分类 ID 列表](https://developers.google.com/youtube/v3/docs/videoCategories/list) ## GitHub 参考项目 ### 推荐项目 | 项目 | 描述 | Star数 | |------|------|--------| | [yt-dlp/yt-dlp](https://github.com/yt-dlp/yt-dlp) | 最活跃的 YouTube 下载工具,支持 trending 提取 | 100k+ | | [pytube/pytube](https://github.com/pytube/pytube) | 轻量级 YouTube 下载库 | 13k+ | | [mitchelljy/Trending-YouTube-Scraper](https://github.com/mitchelljy/Trending-YouTube-Scraper) | 多地区 trending 数据爬取,使用 YouTube Data API | 350+ | | [jecordei/youtube-trending-videos-scraper](https://github.com/jecordei/youtube-trending-videos-scraper) | YouTube trending 页面爬虫 | 26+ | | [gpsyrou/tube-virality](https://github.com/gpsyrou/tube-virality) | 多国家 trending 视频分析项目 | 28+ | | [nubilfi/restful-trends](https://github.com/nubilfi/restful-trends) | RESTful API 获取 Google/TikTok/YouTube/Twitter Trends | - | | [Simple-Python-Scrapy-Scrapers/youtube-scrapy-scraper](https://github.com/Simple-Python-Scrapy-Scrapers/youtube-scrapy-scraper) | Scrapy 框架专业爬虫 | 500+ | | [Y3l4n/Trending-Youtube-Scraper](https://github.com/Y3l4n/Trending-Youtube-Scraper) | 多地区 trending 爬虫 | 200+ | ### 学习资源 - [ScrapeCreators: How to Scrape YouTube Trendings](https://scrapecreators.com/tutorials/how-to-scrape-youtube-trending-with-python/) - [yt-dlp Embedding 文档](https://github.com/yt-dlp/yt-dlp#embedding-yt-dlp) - [YouTube API Multi-Region Tutorial](https://dev.to/ahmet_gedik778845/multi-region-video-discovery-with-youtube-data-api-3o5o) ## 技术文章 ### API 使用 - [Fetch Trending YouTube Videos With YouTube Data API In PHP](https://apibuddy.net/get-trending-youtube-videos-with-youtube-data-api/) - [YouTube API: Find Trending Kids Videos](https://reelmind.ai/blog/youtube-api-find-trending-kids-videos) - [Finding trending videos in selected location](https://stackoverflow.com/questions/73845374/finding-trending-videos-in-selected-location-in-youtube-api-with-location) ### 爬虫技术 - [How to Scrape YouTube Videos in 2026](https://www.scraperapi.com/web-scraping/youtube/) - [Scrape YouTube Videos and comments in Python](https://serpapi.com/blog/scrape-youtube-videos-in-python/) - [How to scrape YouTube using Python [2025 guide]](https://crawlee.dev/blog/scrape-youtube-python) ## 代码片段 ### API 调用示例 ```bash # 获取 US 地区热门视频 curl "https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&chart=mostPopular®ionCode=US&maxResults=50&key=YOUR_API_KEY" ``` ### yt-dlp 命令行 ```bash # 提取 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 合法性**: 在某些司法管辖区使用可能受限,请遵守当地法律