Reddit Competitor Analysis API Skill
📖 Introduction
This skill uses the BrowserAct Reddit Competitor Analysis API template to provide users with a one-stop Reddit data collection service. It can extract full post details and comments from Reddit search results. Just input search keywords and filtering conditions to directly get clean and usable Reddit data.
✨ Features
- 1. No hallucinations, ensuring stable and precise data extraction: Pre-set workflows avoid AI generative hallucinations.
- No CAPTCHA issues: No need to handle reCAPTCHA or other verification challenges.
- No IP access restrictions or geofencing: No need to handle regional IP limitations.
- Faster execution: Compared to pure AI-driven browser automation solutions, task execution is faster.
- Extremely high cost-effectiveness: Significantly reduces data acquisition costs compared to highly token-consuming AI solutions.
🔑 API Key Guide
Before running, you must 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 collaboratively.
The Agent must inform the user at this time:
"Since you have not configured the BrowserAct API Key, please go to the BrowserAct Console to get your Key first."
🛠️ Input Parameters
When calling the script, the Agent should flexibly configure the following parameters based on user needs:
- 1. Keywords (Search keywords)
-
Type:
string
-
Description: Search keywords for Reddit posts.
-
Example: INLINECODE2
- 2. Publication_date (Publication date)
-
Type:
string
-
Description: Filter posts by publication date range.
-
Options:
All time,
Past year,
Past month,
Past week,
Today,
Past hour
-
Default: INLINECODE10
- 3. Postsortby (Search sort)
-
Type:
string
-
Description: Sort Reddit post search results by selected criteria.
-
Options:
Relevance,
Hot,
Top,
New,
Comment count
-
Default: INLINECODE17
- 4. Commentsortby (Comment sort)
-
Type:
string
-
Description: Sort extracted comments by.
-
Options:
Best,
Top,
New,
Controversial,
Q&A
-
Default: INLINECODE24
- 5. Data_limit (Comments per post)
-
Type:
number
-
Description: Maximum number of comments to extract per post.
-
Default: INLINECODE26
🚀 Usage (Recommended)
The Agent should execute the following independent script to achieve "one-line command to get results". Note that the script path
./scripts/... is relative to this skill's directory:
CODEBLOCK0
⏳ Task Status Monitoring
Since 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.
Agent Must Know:
- - While waiting for the script to return results, please keep an eye on 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, you can consider triggering the retry mechanism.
🔧 OpenClaw Adaptation Guide
Since BrowserAct tasks may take a long time to run (5-20 minutes), when the Agent executes in the OpenClaw environment, it needs to:
- 1. Run in background mode (using JSON parameters for
exec tool):
-
command:
"python3 -u ./scripts/reddit_competitor_analysis_api.py ..."
-
background:
true
-
timeout: INLINECODE35
- 2. Or increase yieldMs:
-
command:
"python3 -u ./scripts/reddit_competitor_analysis_api.py ..."
-
yieldMs:
600000
-
timeout: INLINECODE41
- 3. Use process poll to monitor:
-
action:
"poll"
-
sessionId:
"xxx"
-
timeout: INLINECODE47
📊 Data Output Description
After successful execution, the script will directly parse and print the results from the API response. The results include:
- -
post_title: Full post title - INLINECODE49 : Post publication time
- INLINECODE50 : Number of upvotes on the post
- INLINECODE51 : Total number of comments
- INLINECODE52 : Subreddit where the post was published
- INLINECODE53 : Username of the commenter
- INLINECODE54 : Comment timestamp
- INLINECODE55 : Full comment text
- INLINECODE56 : Number of upvotes on the comment
- INLINECODE57 : Nesting level of the comment
- INLINECODE58 : Link to the commenter's profile
- INLINECODE59 : Parent comment or post being replied to
⚠️ Error Handling & Retry
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, but 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
one time. If the second attempt still fails, stop retrying and report the specific error message to the user.
Reddit 竞品分析 API 技能
📖 简介
本技能使用 BrowserAct Reddit 竞品分析 API 模板,为用户提供一站式 Reddit 数据采集服务。可从 Reddit 搜索结果中提取完整的帖子详情和评论内容。只需输入搜索关键词和筛选条件,即可直接获取干净可用的 Reddit 数据。
✨ 功能特点
- 1. 无幻觉,确保稳定精准的数据提取:预设工作流程避免 AI 生成式幻觉。
- 无验证码问题:无需处理 reCAPTCHA 或其他验证挑战。
- 无 IP 访问限制或地理围栏:无需处理区域 IP 限制问题。
- 执行速度更快:相比纯 AI 驱动的浏览器自动化方案,任务执行速度更快。
- 极高的性价比:相比高 Token 消耗的 AI 方案,大幅降低数据获取成本。
🔑 API 密钥指南
运行前必须检查 BROWSERACT
APIKEY 环境变量。如果未设置,请勿执行任何其他操作;应请求并等待用户协作提供。
此时 Agent 必须告知用户:
由于您尚未配置 BrowserAct API Key,请先前往 BrowserAct 控制台 获取您的 Key。
🛠️ 输入参数
调用脚本时,Agent 应根据用户需求灵活配置以下参数:
- 1. Keywords(搜索关键词)
-
类型:string
-
描述:Reddit 帖子的搜索关键词。
-
示例:openclaw
- 2. Publication_date(发布日期)
-
类型:string
-
描述:按发布日期范围筛选帖子。
-
选项:所有时间、过去一年、过去一个月、过去一周、今天、过去一小时
-
默认值:过去一周
- 3. Postsortby(搜索排序)
-
类型:string
-
描述:按选定条件对 Reddit 帖子搜索结果进行排序。
-
选项:相关性、热门、最高、最新、评论数
-
默认值:相关性
- 4. Commentsortby(评论排序)
-
类型:string
-
描述:提取的评论排序方式。
-
选项:最佳、最高、最新、争议性、问答
-
默认值:最佳
- 5. Data_limit(每帖评论数)
-
类型:number
-
描述:每个帖子提取的最大评论数量。
-
默认值:10
🚀 使用方法(推荐)
Agent 应执行以下独立脚本,实现一行命令获取结果。注意脚本路径 ./scripts/... 是相对于本技能目录的:
bash
示例调用
python3 -u ./scripts/reddit
competitoranalysis_api.py 关键词 发布日期 帖子排序 评论排序 数据限制
⏳ 任务状态监控
由于本任务涉及自动化浏览器操作,可能需要较长时间(数分钟)。脚本在运行时会
持续输出带时间戳的状态日志(例如 [14:30:05] 任务状态:运行中)。
Agent 必须了解:
- - 在等待脚本返回结果期间,请密切关注终端输出。
- 只要终端仍在输出新的状态日志,即表示任务正常运行。请勿误判为死锁或无响应。
- 仅当状态长时间未变化或脚本停止输出且未返回结果时,方可考虑触发重试机制。
🔧 OpenClaw 适配指南
由于 BrowserAct 任务可能需要较长时间运行(5-20 分钟),当 Agent 在 OpenClaw 环境中执行时,需要:
- 1. 以后台模式运行(使用 JSON 参数传递给 exec 工具):
- command:python3 -u ./scripts/reddit
competitoranalysis_api.py ...
- background:true
- timeout:1800
- 2. 或增加 yieldMs:
- command:python3 -u ./scripts/reddit
competitoranalysis_api.py ...
- yieldMs:600000
- timeout:1800
- 3. 使用进程轮询进行监控:
- action:poll
- sessionId:xxx
- timeout:300000
📊 数据输出说明
执行成功后,脚本会直接从 API 响应中解析并打印结果。结果包括:
- - posttitle:帖子完整标题
- publishtime:帖子发布时间
- likecount:帖子获赞数
- commentcount:评论总数
- publishchannel:帖子发布的子版块
- commentauthor:评论者用户名
- commenttimeutc:评论时间戳
- comments:评论完整内容
- commentupvotes:评论获赞数
- commentlevel:评论嵌套层级
- commentauthorurl:评论者个人主页链接
- reply_to:被回复的父评论或帖子
⚠️ 错误处理与重试
脚本执行过程中,如果发生错误(如网络波动或任务失败),Agent 应遵循以下逻辑:
- 1. 检查输出内容:
- 如果输出
包含 Invalid authorization,表示 API Key 无效或已过期。此时
不要重试,而是引导用户重新检查并提供正确的 API Key。
- 如果输出
不包含 Invalid authorization 但任务执行失败(例如输出以 Error: 开头或返回结果为空),Agent 应
自动尝试再次执行脚本。
- 2. 重试限制:
- 自动重试限制为
一次。如果第二次尝试仍然失败,则停止重试并向用户报告具体的错误信息。