extracting-youtube-comments-for-research
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExtracting YouTube Comments for Research
提取YouTube评论用于研究
Pulls YouTube video comments for sentiment analysis, question mining, and product feedback. YouTube comments are more considered than TikTok — viewers invest more time before commenting.
获取YouTube视频评论以进行情感分析、问题挖掘和产品反馈。YouTube评论比TikTok评论更具深思性——观众会投入更多时间后才发表评论。
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: Scrape comments from target videos
- [ ] Step 2: Filter and clean dataset
- [ ] Step 3: Analyze by research goal
- [ ] Step 4: Extract top themes and insights
- [ ] Step 5: Deliver comment research report进度:
- [ ] 步骤1:从目标视频中抓取评论
- [ ] 步骤2:筛选并清理数据集
- [ ] 步骤3:根据研究目标进行分析
- [ ] 步骤4:提取核心主题和洞察
- [ ] 步骤5:交付评论研究报告Step 1: Scrape Comments
步骤1:抓取评论
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-comments-scraper"
--input '{"param": "value"}'
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
Save as CSV
保存为CSV格式
node scripts/run_actor.js
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
node scripts/run_actor.js
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
Save as JSON
保存为JSON格式
node scripts/run_actor.js
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
--actor "apidojo~youtube-comments-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-comments-scraper"
Input:
{
"startUrls": [{"url": "[VIDEO_URL_1]"}, {"url": "[VIDEO_URL_2]"}],
"type": "comments",
"maxComments": 500
}
**REST API fallback:**
```bash
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~youtube-comments-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"startUrls": [{"url": "[VIDEO_URL]"}], "type": "comments", "maxComments": 500}'node scripts/run_actor.js
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> 必须在环境变量或`.env`文件中设置`APIFY_TOKEN`。
**如果Apify MCP可用:**Tool: apify:run-actor
Actor: "apidojo~youtube-comments-scraper"
Input:
{
"startUrls": [{"url": "[VIDEO_URL_1]"}, {"url": "[VIDEO_URL_2]"}],
"type": "comments",
"maxComments": 500
}
**REST API备选方案:**
```bash
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~youtube-comments-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"startUrls": [{"url": "[VIDEO_URL]"}], "type": "comments", "maxComments": 500}'Step 2: Clean Dataset
步骤2:清理数据集
- Remove comments < 8 words (usually emoji-only or "great video!")
- Remove self-promotional comments (contain external links)
- Remove creator's own replies (match to channel name)
authorName - Apply filter if set
min_likes_on_comment
- 删除字数少于8个的评论(通常仅含表情或类似"很棒的视频!"的内容)
- 删除含自我推广内容的评论(包含外部链接)
- 删除创作者自己的回复(将与频道名称匹配)
authorName - 如果已设置,则应用筛选条件
min_likes_on_comment
Step 3: Analyze by Goal
步骤3:根据目标进行分析
Questions: Contains "?", "how do you", "what is", "can you"
Pain points: "I struggle", "I can't", "problem is", "doesn't work"
Product feedback: Product mentions + opinion signals
Sentiment: Standard lexical classifier (positive/negative/neutral)
comment_importance = likeCount * 0.60 + replyCount * 10 * 0.40问题类: 包含"?"、"how do you"、"what is"、"can you"
痛点类: 包含"I struggle"、"I can't"、"problem is"、"doesn't work"
产品反馈类: 提及产品+带有观点的表述
情感分析: 使用标准词汇分类器(正面/负面/中性)
comment_importance = likeCount * 0.60 + replyCount * 10 * 0.40Step 4: Edge Cases
步骤4:边缘情况处理
- Comments disabled: Note; try different video from same channel
- Mostly non-English: Report language distribution; filter to English if needed
- Spam invasion: Filter where same username appears > 3 times
- Brigaded comment section: > 50% share coordinated theme → flag as BRIGADED
- 评论已禁用:记录该情况;尝试同一频道的其他视频
- 多数为非英语评论:报告语言分布情况;如有需要筛选出英语评论
- 垃圾评论泛滥:筛选掉同一用户名出现超过3次的评论
- 评论区被操控:超过50%的评论存在协调一致的主题 → 标记为BRIGADED
Output Format
输出格式
undefinedundefinedYouTube Comment Analysis
YouTube评论分析
Videos: [N] | Comments analyzed: [N] | After filtering: [N] | Date: [DATE]
视频数量: [N] | 分析的评论数: [N] | 筛选后评论数: [N] | 日期: [DATE]
Sentiment (if goal = sentiment)
情感分析结果(如果目标为情感分析)
Positive: [X%] | Negative: [X%] | Neutral: [X%]
正面: [X%] | 负面: [X%] | 中性: [X%]
Top 10 Most-Liked Comments
点赞数Top10评论
| # | Comment (excerpt) | Likes | Replies |
|---|
| 序号 | 评论(节选) | 点赞数 | 回复数 |
|---|
Key Themes
核心主题
| Theme | Frequency | Avg Likes | Example |
|---|
| 主题 | 出现频次 | 平均点赞数 | 示例 |
|---|
Most Asked Questions
最常见问题
- "[question]" — [N] viewers
undefined- "[问题内容]" — [N]位观众
undefinedTroubleshooting
故障排除
Few comments returned: YouTube limits access for some videos; try high-comment video from same channel.
Mostly surface-level praise: Use to filter for substantive comments.
Research goal not present: Audience may not engage that way on YouTube; try Reddit or TikTok for this niche.
min_likes_on_comment = 5返回评论数量极少:YouTube对部分视频的访问有限制;尝试同一频道中评论较多的视频。
多数为表面夸赞的评论:使用筛选出有实质内容的评论。
未找到符合研究目标的内容:该受众群体可能不会在YouTube上以这种方式互动;针对该细分领域可尝试Reddit或TikTok。
min_likes_on_comment = 5