scraping-youtube-trending-videos
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScraping Youtube Trending Videos
爬取YouTube热门视频
Raw data collection. No assumed use case — returns the full dataset for downstream analysis.
原始数据采集。不预设使用场景——返回完整数据集以供下游分析。
Inputs
输入参数
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| string | Optional | | Trending category: |
| string | Optional | | Country code (e.g. |
| string | Optional | | Language code (e.g. |
| number | Optional | Unlimited | Maximum videos to return |
| string | Optional | — | JavaScript function to transform each output object |
| 参数 | 类型 | 是否必填 | 默认值 | 说明 |
|---|---|---|---|---|
| string | 可选 | | 热门类别: |
| string | 可选 | | 国家代码(例如 |
| string | 可选 | | 语言代码(例如 |
| number | 可选 | 无限制 | 返回的最大视频数量 |
| string | 可选 | — | 用于转换每个输出对象的JavaScript函数 |
How to Run
运行方式
Using run_actor.js (recommended)
使用run_actor.js(推荐)
bash
undefinedbash
undefinedQuick answer (table)
快速查看结果(表格形式)
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'
Save as CSV
保存为CSV格式
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.csv --format csv
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.csv --format csv
Save as JSON
保存为JSON格式
node scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.json --format json
undefinednode scripts/run_actor.js --actor "apidojo~youtube-trending-scraper" --input '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}' --output results.json --format json
undefinedREST API fallback
REST API备选方案
bash
curl -X POST "https://api.apify.com/v2/acts/apidojo~youtube-trending-scraper/runs" \
-H "Authorization: Bearer $APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'If Apify MCP is available:
Use the Apify MCP tool with actor and the input above.
call_actorapidojo~youtube-trending-scraperbash
curl -X POST "https://api.apify.com/v2/acts/apidojo~youtube-trending-scraper/runs" \
-H "Authorization: Bearer $APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type": "n", "gl": "us", "hl": "en", "maxItems": 50}'如果Apify MCP可用:
使用Apify MCP的工具,指定actor为并传入上述输入参数。
call_actorapidojo~youtube-trending-scraperOutput Fields
输出字段
| Field | Type | Description |
|---|---|---|
| string | Always |
| string | Video ID |
| string | Video title |
| string | Video URL |
| string | Video description |
| number | Duration in seconds |
| number | View count |
| number | Like count |
| string | Availability status |
| string | Channel ID |
| string | Channel name |
| string | Channel URL |
| array | Video tags/keywords |
| boolean | Live stream flag |
| array | Thumbnail objects |
| 字段 | 类型 | 描述 |
|---|---|---|
| string | 固定为 |
| string | 视频ID |
| string | 视频标题 |
| string | 视频URL |
| string | 视频描述 |
| number | 视频时长(秒) |
| number | 观看量 |
| number | 点赞数 |
| string | 可用状态 |
| string | 频道ID |
| string | 频道名称 |
| string | 频道URL |
| array | 视频标签/关键词 |
| boolean | 直播标识 |
| array | 缩略图对象 |
Edge Cases
边缘情况
- No results for category: Some countries may not have all category pages. Fall back to type=.
n - Empty results: YouTube may show different trending per session — retry.
- Region mismatch: gl and hl must be valid ISO codes.
- Data freshness: Trending changes frequently — data reflects a point-in-time snapshot.
- 类别无结果:部分国家可能没有全部分类页面,回退到。
type=n - 结果为空:YouTube可能会根据会话显示不同的热门内容——请重试。
- 区域不匹配:和
gl必须是有效的ISO代码。hl - 数据时效性:热门内容变化频繁——数据反映的是某一时刻的快照。