YouTube Comments API Automation Skill
📖 Introduction
This skill provides a one-stop extraction service for YouTube video and comment data through the BrowserAct YouTube Comments API template. It can extract structured video results along with their respective comments directly from YouTube. By simply providing search keywords, comment limits, and scroll counts, you can acquire clean and ready-to-use video and comment datasets directly.
✨ Features
- 1. Zero Hallucination, Ensuring Stable and Accurate Data Extraction: Pre-configured workflows avoid AI generative hallucinations.
- No CAPTCHA Issues: No need to handle reCAPTCHA or other verification challenges.
- No IP Access Restrictions or Geo-fencing: No need to deal with regional IP limits.
- More Agile Execution Speed: Faster task execution compared to pure AI-driven browser automation solutions.
- Extremely High Cost-Efficiency: Significantly reduces data acquisition costs compared to AI solutions that consume a large number of tokens.
🔑 API Key Guidance Process
Before running, you must first check the
BROWSERACT_API_KEY environment variable. If it is not set, do not take any other actions; you should request and wait for the user to provide it.
At this point, the Agent must inform the user:
"Since you have not configured the BrowserAct API Key yet, please go to the BrowserAct Console first to get your Key."
🛠️ Input Parameters
When invoking the script, the Agent should flexibly configure the following parameters based on user needs:
- 1. keywords
-
Type:
string
-
Description: Search keywords used to find videos on YouTube. Can be any keyword or phrase.
-
Example:
AI,
automation,
web scraping
-
Default: INLINECODE5
- 2. Comments_limit
-
Type:
number
-
Description: Maximum number of comments to extract per video.
-
Example:
10,
20,
50
-
Default: INLINECODE10
- 3. Scroll_count
-
Type:
number
-
Description: Number of times to scroll in the comments section to load more comments before extraction.
-
Example:
1,
2,
5,
10
-
Default: INLINECODE16
🚀 Invocation Method (Recommended)
The Agent should execute the following standalone script to achieve "one command, get results":
CODEBLOCK0
⏳ Running Status Monitoring
Since this task involves automated browser operations, it may take a long time (several minutes). While running, the script will
continuously output timestamped status logs (e.g.,
[14:30:05] Task Status: running).
Agent Instructions:
- - While waiting for the script to return a result, please keep monitoring the terminal output.
- As long as the terminal is still outputting new status logs, it means the task is running normally. Do not misjudge it as a deadlock or unresponsiveness.
- Only if the status remains unchanged for a long time or the script stops outputting without returning a result, should you consider triggering the retry mechanism.
📊 Data Output Description
Upon successful execution, the script will directly parse and print the results from the API response. The results include two linked datasets:
Video fields:
- -
video_name: Video title shown in the list - INLINECODE19 : Video URL
- INLINECODE20 : Published time
- INLINECODE21 : View count
Comment fields:
- -
commenter_name: Comment author display name - INLINECODE23 : Comment author channel URL
- INLINECODE24 : Comment content
- INLINECODE25 : Comment publish time
- INLINECODE26 : Like count for the comment
- INLINECODE27 : Number of replies
⚠️ Error Handling & Retry
During the execution of the script, if an error occurs (such as network fluctuations or task failure), the Agent should follow this logic:
- 1. Check the Output Content:
- If the output
contains "Invalid authorization", it means the API Key is invalid or expired. At this time,
do not retry; you should guide the user to recheck and provide the correct API Key.
- If the output
does not contain "Invalid authorization" but the task fails (e.g., the output starts with
Error: or returns an empty result), the Agent should
automatically try to execute the script one more time.
- 2. Retry Limit:
- Automatic retries are limited to
one time only. If the second attempt still fails, stop retrying and report the specific error message to the user.
🌟 Typical Use Cases
- 1. Audience Insight: Turning comments into product feedback and sentiment signals based on specific keywords.
- Content Research: Understanding what viewers are discussing under popular video topics.
- Competitive Monitoring: Tracking comments and feedback on competitors' YouTube channels.
- Community Insight: Analyzing what users care about in a specific niche like automation or AI.
- Topic Tracking: Monitoring the public response and interaction for trending search terms.
- Sentiment Analysis: Gathering raw text data from comments to evaluate viewer opinions.
- Objections and Feature Requests: Identifying user pain points from product-related video comments.
- Automated Data Integration: Sending video and comment data directly into CRM or BI tools via API.
- Engagement Metrics Collection: Tracking likes and reply counts for top comments.
- Market Research: Extracting a large set of video metadata combined with user discussions for market studies.
YouTube评论API自动化技能
📖 简介
本技能通过BrowserAct YouTube评论API模板,提供YouTube视频和评论数据的一站式提取服务。可直接从YouTube提取结构化的视频结果及其对应的评论。只需提供搜索关键词、评论限制和滚动次数,即可直接获取干净、可直接使用的视频和评论数据集。
✨ 功能特点
- 1. 零幻觉,确保数据提取稳定准确:预配置的工作流程避免了AI生成式幻觉。
- 无验证码问题:无需处理reCAPTCHA或其他验证挑战。
- 无IP访问限制或地理围栏:无需处理区域IP限制。
- 更敏捷的执行速度:相比纯AI驱动的浏览器自动化解决方案,任务执行更快。
- 极高的成本效益:相比消耗大量token的AI解决方案,显著降低数据获取成本。
🔑 API密钥引导流程
运行前,必须首先检查BROWSERACT
APIKEY环境变量。如果未设置,不要执行任何其他操作;应请求并等待用户提供。
此时,Agent必须告知用户:
由于您尚未配置BrowserAct API密钥,请先前往BrowserAct控制台获取您的密钥。
🛠️ 输入参数
调用脚本时,Agent应根据用户需求灵活配置以下参数:
- 1. keywords
-
类型:string
-
描述:用于在YouTube上搜索视频的关键词。可以是任何关键词或短语。
-
示例:AI、自动化、网页抓取
-
默认值:AI
- 2. Comments_limit
-
类型:number
-
描述:每个视频提取的最大评论数量。
-
示例:10、20、50
-
默认值:10
- 3. Scroll_count
-
类型:number
-
描述:在提取前,评论区域滚动的次数,以加载更多评论。
-
示例:1、2、5、10
-
默认值:2
🚀 调用方法(推荐)
Agent应执行以下独立脚本,实现一键执行,获取结果:
bash
示例调用
python -u ./scripts/youtube
commentsapi.py keywords Comments
limit Scrollcount
⏳ 运行状态监控
由于此任务涉及自动化浏览器操作,可能需要较长时间(数分钟)。运行时,脚本将
持续输出带时间戳的状态日志(例如[14:30:05] 任务状态:运行中)。
Agent指令:
- - 在等待脚本返回结果期间,请持续监控终端输出。
- 只要终端仍在输出新的状态日志,即表示任务正常运行。不要误判为死锁或无响应。
- 仅当状态长时间保持不变,或脚本停止输出且未返回结果时,才应考虑触发重试机制。
📊 数据输出说明
成功执行后,脚本将直接从API响应中解析并打印结果。结果包含两个关联的数据集:
视频字段:
- - videoname:列表中显示的视频标题
- videourl:视频URL
- videopublicationtime:发布时间
- videoviewcount:观看次数
评论字段:
- - commentername:评论作者显示名称
- commenterurl:评论作者频道URL
- commenttext:评论内容
- commentpublishdate:评论发布时间
- commentlikes:评论点赞数
- reply_count:回复数量
⚠️ 错误处理与重试
在脚本执行过程中,如果发生错误(如网络波动或任务失败),Agent应遵循以下逻辑:
- 1. 检查输出内容:
- 如果输出
包含Invalid authorization,表示API密钥无效或已过期。此时
不要重试,应引导用户重新检查并提供正确的API密钥。
- 如果输出
不包含Invalid authorization但任务失败(例如输出以Error:开头或返回空结果),Agent应
自动尝试再次执行脚本一次。
- 2. 重试限制:
- 自动重试仅限
一次。如果第二次尝试仍然失败,停止重试并向用户报告具体的错误信息。
🌟 典型使用场景
- 1. 受众洞察:基于特定关键词,将评论转化为产品反馈和情感信号。
- 内容研究:了解热门视频话题下观众的讨论内容。
- 竞品监控:追踪竞争对手YouTube频道的评论和反馈。
- 社区洞察:分析用户在自动化或AI等特定领域的关注点。
- 话题追踪:监控热门搜索词条的公众反应和互动情况。
- 情感分析:收集评论中的原始文本数据,评估观众观点。
- 异议与功能请求:从产品相关视频评论中识别用户痛点。
- 自动化数据集成:通过API将视频和评论数据直接发送到CRM或BI工具。
- 互动指标收集:追踪热门评论的点赞数和回复数。
- 市场研究:提取大量视频元数据并结合用户讨论进行市场研究。