YouTube Search API Skill
📖 Introduction
This skill provides users with a one-stop YouTube search data extraction service through BrowserAct's YouTube Search API template. It can extract structured fields directly from the YouTube search results list. Simply provide the search keywords and limit conditions to get clean, usable video, shorts, channel, or playlist data.
✨ Features
- 1. No hallucinations, ensuring stable and accurate data extraction: Pre-set workflows avoid AI generative hallucinations.
- No CAPTCHA issues: No need to handle reCAPTCHA or other verification challenges.
- No IP access limits or geo-fencing: No need to deal with regional IP restrictions.
- More agile execution speed: Compared to pure AI-driven browser automation solutions, task execution is faster.
- Extremely high cost-effectiveness: Significantly reduces data acquisition costs compared to AI solutions that consume a large number of tokens.
🔑 API Key Setup Flow
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's collaboration to provide it.
The Agent must inform the user at this time:
"Since you have not configured the BrowserAct API Key, please go to the BrowserAct Console first to get your Key."
🛠️ Input Parameters
When calling the script, the Agent should flexibly configure the following parameters based on the user's needs:
- 1. KeyWords
-
Type:
string
-
Description: Search keywords used on YouTube. Can be any keyword or phrase.
-
Example:
AI,
automation,
n8n, INLINECODE5
- 2. Video_type
-
Type:
string
-
Description: Which results tab to extract from.
-
Supported values:
Videos,
Shorts,
Channels,
Playlists
-
Default: INLINECODE11
- 3. Date_limit
-
Type:
number
-
Description: Maximum number of items to extract from the search results list.
-
Example:
20,
50,
100
-
Default: INLINECODE16
🚀 Usage (Recommended)
The Agent should achieve "one-command results" by executing the following independent script:
CODEBLOCK0
⏳ Execution Status Monitoring
Because this task involves automated browser operations, it may take a long time (several minutes). The script will
continuously output status logs with timestamps (e.g.,
[14:30:05] Task Status: running) while running.
Notice to Agent:
- - While waiting for the script to return results, please keep paying attention to the terminal output.
- As long as the terminal is still outputting new status logs, it means the task is running normally. Please do not mistakenly judge it as a deadlock or unresponsiveness.
- Only if the status remains unchanged for a long time or the script stops outputting and no result is returned, can you consider triggering the retry mechanism.
📊 Data Output
After successful execution, the script will parse and print the result directly from the API response. The extracted data includes:
- -
title: Title shown in search results - INLINECODE19 : Short description snippet (when available)
- INLINECODE20 : View count displayed in results
- INLINECODE21 : Publish time displayed in results
- INLINECODE22 : Result item URL
⚠️ Error Handling & Retry Mechanism
During the execution of the script, if an error occurs (such as network fluctuation 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, and you should guide the user to recheck and provide the correct API Key.
- If the output
does not contain "Invalid authorization" but the task execution fails (for example, the output starts with
Error: or the returned result is empty), the Agent should
automatically try to execute the script again.
- 2. Retry limit:
- Automatic retry is limited to
only once. If the second attempt still fails, stop retrying and report the specific error message to the user.
🌟 Typical Use Cases
- 1. Keyword-first discovery: Build topic pools and content datasets directly from search intent.
- Competitor scanning: Search for competitor brand names and extract top related videos.
- Content monitoring: Regularly extract search results for specific industry keywords to see what's trending.
- Channel research: Search for channels within a specific niche and gather their URLs.
- Tutorial aggregation: Find and extract educational videos for specific software or tools.
- Shorts tracking: Monitor YouTube Shorts for trending hashtags or topics.
- Playlist extraction: Find curated playlists for specific subjects.
- Market research: Build structured datasets of search results for market analysis.
- Creator outreach: Find emerging creators in a particular field for collaboration.
- View count analysis: Compare view counts of the top videos for various keywords.
YouTube 搜索 API 技能
📖 简介
本技能通过 BrowserAct 的 YouTube 搜索 API 模板,为用户提供一站式 YouTube 搜索数据提取服务。它可以直接从 YouTube 搜索结果列表中提取结构化字段。只需提供搜索关键词和限制条件,即可获得干净可用的视频、Shorts、频道或播放列表数据。
✨ 功能特点
- 1. 无幻觉,确保稳定准确的数据提取:预设工作流程避免了 AI 生成式幻觉。
- 无验证码问题:无需处理 reCAPTCHA 或其他验证挑战。
- 无 IP 访问限制或地理围栏:无需处理区域 IP 限制。
- 更敏捷的执行速度:相比纯 AI 驱动的浏览器自动化方案,任务执行更快。
- 极高的性价比:相比消耗大量 Token 的 AI 方案,显著降低数据获取成本。
🔑 API 密钥设置流程
运行前,必须首先检查 BROWSERACT
APIKEY 环境变量。如果未设置,不要执行任何其他操作;应请求并等待用户配合提供。
此时 Agent 必须告知用户:
由于您尚未配置 BrowserAct API 密钥,请先前往 BrowserAct 控制台 获取您的密钥。
🛠️ 输入参数
调用脚本时,Agent 应根据用户需求灵活配置以下参数:
- 1. 关键词
-
类型:string
-
描述:在 YouTube 上使用的搜索关键词。可以是任何关键词或短语。
-
示例:AI、自动化、n8n、网页抓取
- 2. 视频类型
-
类型:string
-
描述:从哪个结果标签页提取数据。
-
支持的值:Videos、Shorts、Channels、Playlists
-
默认值:Videos
- 3. 数量限制
-
类型:number
-
描述:从搜索结果列表中提取的最大条目数。
-
示例:20、50、100
-
默认值:100
🚀 使用方法(推荐)
Agent 应通过执行以下独立脚本来实现一键出结果:
bash
调用示例
python -u ./scripts/youtube
searchapi.py 关键词 视频类型 数量限制
⏳ 执行状态监控
由于此任务涉及自动化浏览器操作,可能需要较长时间(几分钟)。脚本在运行时会
持续输出带时间戳的状态日志(例如 [14:30:05] 任务状态:运行中)。
对 Agent 的提示:
- - 在等待脚本返回结果期间,请持续关注终端输出。
- 只要终端仍在输出新的状态日志,说明任务正常运行。请不要误判为死锁或无响应。
- 仅当状态长时间不变或脚本停止输出且未返回结果时,才可考虑触发重试机制。
📊 数据输出
执行成功后,脚本将直接从 API 响应中解析并打印结果。提取的数据包括:
- - title:搜索结果中显示的标题
- description:简短描述片段(如有)
- viewcount:结果中显示的观看次数
- publishedat:结果中显示的发布时间
- url:结果条目的 URL
⚠️ 错误处理与重试机制
脚本执行过程中,如果发生错误(如网络波动或任务失败),Agent 应遵循以下逻辑:
- 1. 检查输出内容:
- 如果输出
包含 Invalid authorization,说明 API 密钥无效或已过期。此时
不要重试,应引导用户重新检查并提供正确的 API 密钥。
- 如果输出
不包含 Invalid authorization 但任务执行失败(例如输出以 Error: 开头或返回结果为空),Agent 应
自动尝试重新执行脚本。
- 2. 重试限制:
- 自动重试
仅限一次。如果第二次尝试仍然失败,则停止重试并向用户报告具体的错误信息。
🌟 典型使用场景
- 1. 关键词优先发现:直接从搜索意图构建话题池和内容数据集。
- 竞品扫描:搜索竞品品牌名称并提取相关热门视频。
- 内容监控:定期提取特定行业关键词的搜索结果,了解热门趋势。
- 频道研究:搜索特定细分领域的频道并收集其 URL。
- 教程聚合:查找并提取特定软件或工具的教学视频。
- Shorts 追踪:监控 YouTube Shorts 的热门标签或话题。
- 播放列表提取:查找特定主题的精选播放列表。
- 市场研究:构建搜索结果的结构化数据集用于市场分析。
- 创作者拓展:发现特定领域的新兴创作者以寻求合作。
- 观看量分析:比较不同关键词下热门视频的观看次数。