scraping-youtube-channel-data
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScraping YouTube Channel Data
抓取YouTube频道数据
Exports channel-level statistics and optional video catalog for any YouTube channel URL or handle.
导出任意YouTube频道URL或频道标识对应的频道级统计数据及可选视频目录。
Prerequisites
前提条件
- environment variable set
APIFY_TOKEN - Optional: Apify MCP server installed
- 已设置环境变量
APIFY_TOKEN - 可选:已安装Apify MCP服务器
Inputs
输入参数
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| array | Optional | | YouTube URLs — channels, playlists, Shorts, search results |
| array | Optional | | YouTube channel handles (e.g. |
| boolean | Optional | | Retrieve trending videos |
| array | Optional | | Search keywords |
| string | Optional | | Country code for results (e.g. |
| string | Optional | | Language code (e.g. |
| string | Optional | | Upload date filter: |
| string | Optional | | Duration filter: |
| string | Optional | | Feature filter: |
| string | Optional | | Sort order for search results |
| number | Optional | Unlimited | Maximum videos to return |
| string | Optional | — | JavaScript function to transform each output object |
| 参数 | 类型 | 是否必填 | 默认值 | 说明 |
|---|---|---|---|---|
| 数组 | 可选 | | YouTube链接 — 频道、播放列表、Shorts、搜索结果 |
| 数组 | 可选 | | YouTube频道标识(例如 |
| 布尔值 | 可选 | | 获取热门视频 |
| 数组 | 可选 | | 搜索关键词 |
| 字符串 | 可选 | | 结果对应的国家代码(例如 |
| 字符串 | 可选 | | 语言代码(例如 |
| 字符串 | 可选 | | 上传时间筛选: |
| 字符串 | 可选 | | 时长筛选: |
| 字符串 | 可选 | | 功能筛选: |
| 字符串 | 可选 | | 搜索结果排序方式 |
| 数字 | 可选 | 无限制 | 返回的最大视频数量 |
| 字符串 | 可选 | — | 用于转换每个输出对象的JavaScript函数 |
Workflow
工作流程
Progress:
- [ ] Step 1: Normalize channel URLs
- [ ] Step 2: Run youtube-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver channel dataset进度:
- [ ] 步骤1:标准化频道URL
- [ ] 步骤2:运行youtube-scraper
- [ ] 步骤3:轮询直至状态为SUCCEEDED
- [ ] 步骤4:交付频道数据集Step 2: Run the Actor
步骤2:运行Actor
Recommended — run_actor.js (handles waiting, output, and file saving automatically):
bash
undefined推荐方式 — run_actor.js(自动处理等待、输出及文件保存):
bash
undefinedQuick answer (prints table to chat)
快速查看(在聊天窗口打印表格)
node scripts/run_actor.js
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
Save as CSV
保存为CSV
node scripts/run_actor.js
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
node scripts/run_actor.js
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
Save as JSON
保存为JSON
node scripts/run_actor.js
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> `APIFY_TOKEN` must be set in environment or `.env` file.
**If Apify MCP is available:**Tool: apify:run-actor
Actor: "apidojo~youtube-channel-scraper"
Input:
{
"channelUrls": ["https://www.youtube.com/@channelhandle"],
"maxVideos": 30
}
**REST API fallback:**
```bash
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~youtube-channel-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"channelUrls": ["https://www.youtube.com/@channelhandle"], "maxVideos": 30}'Save as . Poll until :
idRUN_IDstatus = SUCCEEDEDbash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'Fetch results:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"node scripts/run_actor.js
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
--actor "apidojo~youtube-channel-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> 必须在环境变量或`.env`文件中设置`APIFY_TOKEN`。
**若Apify MCP可用:**工具: apify:run-actor
Actor: "apidojo~youtube-channel-scraper"
输入:
{
"channelUrls": ["https://www.youtube.com/@channelhandle"],
"maxVideos": 30
}
**REST API备选方案:**
```bash
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~youtube-channel-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"channelUrls": ["https://www.youtube.com/@channelhandle"], "maxVideos": 30}'保存为,轮询直至:
idRUN_IDstatus = SUCCEEDEDbash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'获取结果:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"Step 3: Handle Edge Cases
步骤3:处理边缘情况
- Channel URL not found: Handle may have changed — verify on YouTube.
- Hidden subscriber count: Some channels hide subscriber counts; field returns null — flag these.
- Age-restricted channel: May return limited metadata.
- 频道URL未找到:频道标识可能已更改,请在YouTube上验证。
- 隐藏订阅数:部分频道会隐藏订阅数,该字段将返回null,请标记此类频道。
- 年龄限制频道:可能仅返回有限的元数据。
Output Format
输出格式
undefinedundefinedYouTube Channel Dataset
YouTube频道数据集
Channels requested: N | Returned: N
| Channel | Subscribers | Total Views | Videos | Joined | Country | Recent Avg Views |
|---|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... | ... |
Available fields: channelName, channelId, subscriberCount, viewCount, videoCount,
country, joinedDate, description, channelUrl, recentVideos[]
undefined请求的频道数:N | 返回的频道数:N
| 频道 | 订阅数 | 总观看量 | 视频数 | 入驻时间 | 国家 | 近期平均观看量 |
|---|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... | ... |
可用字段:channelName、channelId、subscriberCount、viewCount、videoCount,
country、joinedDate、description、channelUrl、recentVideos[]
undefinedTroubleshooting
故障排查
Hidden subscriber count: YouTube allows channels to hide this — return and note in output.
Large video catalogs: Set max per run to avoid timeouts.
nullmaxVideos: 100隐藏订阅数:YouTube允许频道隐藏该数据 — 返回并在输出中注明。
大型视频目录:每次运行设置上限以避免超时。
nullmaxVideos: 100