extracting-youtube-comments-for-research

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Extracting 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

前提条件

  • APIFY_TOKEN
    environment variable set
  • Optional: Apify MCP server installed
  • 已设置
    APIFY_TOKEN
    环境变量
  • 可选:已安装Apify MCP服务器

Inputs

输入参数

ParameterTypeRequiredDefaultNotes
startUrls
arrayOptional
[]
YouTube URLs — channels, playlists, Shorts, search results
youtubeHandles
arrayOptional
[]
YouTube channel handles (e.g.
@kurzgesagt
)
getTrending
booleanOptional
false
Retrieve trending videos
keywords
arrayOptional
[]
Search keywords
gl
stringOptional
us
Country code for results (e.g.
US
,
GB
)
hl
stringOptional
en
Language code (e.g.
en
,
de
)
uploadDate
stringOptional
all
Upload date filter:
any
,
hour
,
today
,
week
,
month
,
year
duration
stringOptional
all
Duration filter:
any
,
short
,
long
features
stringOptional
all
Feature filter:
4k
,
hd
,
live
,
cc
,
3d
,
hdr
, etc.
sort
stringOptional
r
Sort order for search results
maxItems
numberOptionalUnlimitedMaximum videos to return
customMapFunction
stringOptionalJavaScript function to transform each output object
参数类型是否必填默认值说明
startUrls
数组可选
[]
YouTube链接——频道、播放列表、Shorts、搜索结果
youtubeHandles
数组可选
[]
YouTube频道标识(例如
@kurzgesagt
getTrending
布尔值可选
false
获取热门视频
keywords
数组可选
[]
搜索关键词
gl
字符串可选
us
结果对应的国家代码(例如
US
GB
hl
字符串可选
en
语言代码(例如
en
de
uploadDate
字符串可选
all
上传日期筛选:
any
hour
today
week
month
year
duration
字符串可选
all
时长筛选:
any
short
long
features
字符串可选
all
功能筛选:
4k
hd
live
cc
3d
hdr
sort
字符串可选
r
搜索结果的排序方式
maxItems
数字可选无限制返回的最大视频数量
customMapFunction
字符串可选用于转换每个输出对象的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
undefined

Quick answer (prints table to chat)

快速结果(在聊天中打印表格)

node scripts/run_actor.js
--actor "apidojo~youtube-comments-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--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
node scripts/run_actor.js
--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
> `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
> 必须在环境变量或`.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
    authorName
    to channel name)
  • Apply
    min_likes_on_comment
    filter if set
  • 删除字数少于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.40

Step 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

输出格式

undefined
undefined

YouTube 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)LikesReplies
序号评论(节选)点赞数回复数

Key Themes

核心主题

ThemeFrequencyAvg LikesExample
主题出现频次平均点赞数示例

Most Asked Questions

最常见问题

  1. "[question]" — [N] viewers
undefined
  1. "[问题内容]" — [N]位观众
undefined

Troubleshooting

故障排除

Few comments returned: YouTube limits access for some videos; try high-comment video from same channel. Mostly surface-level praise: Use
min_likes_on_comment = 5
to filter for substantive comments. Research goal not present: Audience may not engage that way on YouTube; try Reddit or TikTok for this niche.
返回评论数量极少:YouTube对部分视频的访问有限制;尝试同一频道中评论较多的视频。 多数为表面夸赞的评论:使用
min_likes_on_comment = 5
筛选出有实质内容的评论。 未找到符合研究目标的内容:该受众群体可能不会在YouTube上以这种方式互动;针对该细分领域可尝试Reddit或TikTok。