📝 Introduction
A Weibo comment analysis tool. Enter a Weibo post link to view the first-level comment data of that post, with support for paginated browsing and AI sentiment analysis. Display all comments on the current page and the AI summary analysis in the conversation, while generating an interactive HTML report containing the current page data and summary.
✨ Features
| Feature Module | Capability Description | Core Value |
|---|---|---|
| Comment Query | Enter a Weibo post link to query comments | View comments of any post with one click |
| Paginated Browsing | Support browsing results across multiple pages | Explore more comments page by page |
| AI Summary | Four-dimensional sentiment analysis (positive/negative/needs/competitors) | Quickly understand the overall comment sentiment |
| HTML Report | Dark-theme interactive report | Save/share analysis results offline |
🔑 Authentication
Get API Key
Please go to RedFox Hub to get the API KEY
Configure API Key
Option 1: Taking Qoder as an example, add REDFOX_API_KEY to ~/.openclaw/openclaw.json :
{ "env": { "REDFOX_API_KEY": "ak_xxxx..." } }
Option 2: Terminal configuration
export REDFOX_API_KEY="ak_xxxx..."
🔄 Workflow
Step 1: Understand user intent and extract opusId
1. Extract opusId from the Weibo post link
- If the user provides a post link (e.g.,
https://weibo.com/1784473157/R8X4f2lnq), extract the opusId from it (R8X4f2lnq) - If the user directly provides an opusId, use it directly
- If the user's intent is vague (e.g., "help me check the comments"), proactively ask: "Please provide the Weibo post link"
- Do not guess and call the script without the user providing a link
- If the user queried the comments of a post in the previous conversation turn, and the current input is vague (e.g., "next page", "comment analysis"), use the opusId from the previous turn
2. Identify the page number parameter
- User mentions "next page", "page 2" → corresponding page number, and use the max_cursor returned in the previous turn
- User mentions "previous page" → current page - 1
- No page number mentioned → default to page 1
Step 2: Call the query script (automatically generates HTML)
⚠️ Each call requests only one page of data (one API request); do not initiate multiple calls to pull multiple pages without authorization.
The script automatically generates an HTML report on each call(including {{PLACEHOLDER}} placeholders, with analysis data not filled in). The terminal display and HTML are based onthe same API call, ensuring data consistency.
python3 ~/.agents/skills/weibo-comment-search/scripts/weibo_comment_search.py "<博文链接或opusId>" [--page 页码] [--cursor 游标] [--output-dir 目录]
Parameter Description:
| Parameter | Description | Default Value |
|---|---|---|
| input | Weibo post link or opusId | — |
--page |
Page number, starting from 1 | 1 |
--cursor |
Pagination cursor (0 for the first page, subsequently passed in from the returned max_cursor) | 0 |
--no-html |
Skip HTML report generation | — |
--output-dir |
HTML output directory | ~/Downloads/QoderReports |
The script outputs in JSON format:
| Field | Description |
|---|---|
opus_id |
Post opusId |
comments |
Comment list |
max_cursor |
Next page cursor |
has_next |
Whether there is a next page (true/false) |
page |
Current page number |
html_path |
Path of the generated HTML report (contains placeholders, to be filled in later) |
Fields for each comment:
| Field | Description |
|---|---|
nickname |
User nickname |
uid |
User uid |
user_url |
User homepage link (https://weibo.com/{uid}) |
content |
Comment content |
comment_like_num |
Like count (raw number) |
comment_like_num_fmt |
Like count (formatted) |
create_time |
Publish time |
Note: At this point the HTML report only contains the raw comment data, and the analysis placeholders (
{{PLACEHOLDER}}) are to be filled in after user confirmation.
Step 3: Determine the result and display it
Case A: comments count > 0 (has comments)
A1. Inform the user of the query scope
📊 Post
{opus_id}found Ncomments (page {page}), the detailed data is as follows:
A2. Render the Markdown table (display all)
| # | 用户 | 评论内容 | 点赞 | 发布时间 |
|---|------|----------|------|----------|
| 1 | [nickname](https://weibo.com/uid) | 评论内容 | 305 | 2025-07-10 14:30:25 |
Formatting rules:
- Render the user nickname as a hyperlink:
[nickname](user_url), jumping to the user homepage - Like count
< 10000raw number,≥ 10000displayx.xw - Display the publish time in full with year, month, day, hour, minute, and second
- Truncate comment content exceeding 50 characters and add
..., display when the content is empty- - ⚠️ All comments on the current page must be displayed, no truncation allowed
A3. AI comment summary (⚠️ must be output for every query (including pagination))
First page: Based on all comments obtained on the current page, perform a four-dimensional sentiment analysis.
After pagination: Based onall cumulative data from all pages obtained so farperform a comprehensive analysis, rather than analyzing only the current single page. When analyzing, indicate the cumulative total count.
Before analysis, it is necessary to understand the background of Weibo hot topics(hot search events, fan culture, celebrity updates, social issue context).
📈 Comment summary analysis (based on {total} comments)
✅ Positive reviews ({positive_ratio}%)
- {point 1}
- {point 2}
- ...
⚠️ Negative reviews ({negative_ratio}%)
- {point 1}
- {point 2}
- ...
💡 User needs ({demand_ratio}%)
- {point 1}
- {point 2}
- ...
🔍 Competitor comparison public opinion ({competitor_ratio}%)
- {Output only when competitors are mentioned in the comments, otherwise output "no competitors mentioned"}
- {competitor name}: {public opinion point}
Analysis requirements:
- Each point must cite representative comments (extract keywords/phrases)
- The percentage is the proportion of comments mentioning that type relative to the total number of comments
- The sum of the proportions of the four categories positive/negative/needs/competitors may exceed 100% (a single comment may contain multiple types of information at the same time)
- Must understand the Weibo context: Identify fan slang (such as "抱走" "纯路人" "yyds" "打call", etc.), trending topic backgrounds, and celebrity-related public opinion
A4. Pagination prompt (⚠️ immediately after A3, must be output every time)
- If
has_nextis true:
📄 Currently page {page} . Reply "next page" to continue viewing.
- If
has_nextis false:
📄 Currently page {page} , there is no more data.
⚠️ A1~A4 must be completed consecutively in the same round of output, and no step may be omitted.
After A4 is output,ask the user whether an HTML visualization report needs to be generated:
📊 Do you need to generate an HTML visualization report?
If the user replies with confirmation words such as "yes", "need", "generate", "html", etc., then execute the following steps (no need to call the script again, the HTML file has already been generated in Step 2):
① Backfill the AI analysis results into the HTML
Call backfill_html.py to backfill the AI analysis results into the {{PLACEHOLDER}} placeholder in the HTML:
python3 ~/.agents/skills/weibo-comment-search/scripts/backfill_html.py "<html_path>" --analysis-json '{
"positive_ratio": <正整数>,
"negative_ratio": <正整数>,
"demand_ratio": <正整数>,
"competitor_ratio": <正整数>,
"positive_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>",
"negative_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>",
"demand_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>",
"competitor_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>"
}'
JSON field description:
| Field | Type | Description | Example |
|---|---|---|---|
positive_ratio |
int | Proportion of positive reviews (pure number, excluding %) | 45 |
negative_ratio |
int | Proportion of negative reviews | 30 |
demand_ratio |
int | Proportion of user needs | 15 |
competitor_ratio |
int | Proportion of competitor comparisons | 15 |
positive_summary |
string | Positive review summary (HTML format <ul><li>...</li></ul>) |
see example |
negative_summary |
string | Negative review summary | same as above |
demand_summary |
string | User needs summary | same as above |
competitor_summary |
string | Competitor comparison summary | same as above |
Note: The JSON string parameter contains double quotes; in Bash, wrap it in single quotes, and internal double quotes need to be escaped \". If the content contains single quotes, pass it via stdin:echo '...' | python3 backfill_html.py "<html_path>"
② Open the HTML report:
open "<html_path>"
Case B: comments count = 0 (no comments)
B1. Prompt
😔 This post has no comment data yet.
Step 4: Pagination handling
When the user replies "next page", "previous page", "page N":
- Reuse the opusId extracted in Step 1
- Use the
max_cursorreturned in the previous round as the new--cursor - Calculate the new page number
- Call the script again (consistent with Step 2, automatically generate HTML):
python3 .../weibo_comment_search.py "<opusId>" --page <page> --cursor <cursor> - Fully execute A1~A4 of Step 3, where:
- A1/A2: only display the current page data (display scope unchanged)
- A3 comment analysis: conduct a comprehensive analysis based on the cumulative data of all pages obtained so far (from page 1 to the current page), in the title {total} is the cumulative total number of items
- After A4, ask the user whether the current page HTML needs to be generated (same as the process at the end of Step 3,no need to call the script again)
Step 5: Error handling
| Error type | Handling method |
|---|---|
| No API Key | Prompt to configure REDFOX_API_KEY and provide configuration guidance |
| Invalid post link | Prompt: "Unable to extract opusId, please check whether the blog post link is correct" |
| API returned an error | Display the error code and error message |
| Retrieved 0 comments | Prompt "This blog post has no comments yet" and suggest checking whether the blog post exists or has been deleted |
| Network request timed out | Prompt "Network request timed out, please try again later" |
📋 Dependencies
# 脚本使用 urllib(Python 标准库),无需额外安装依赖
🎯 Usage Examples
Example 1: View comments for a specified blog post
用户:查看微博 https://weibo.com/1784473157/R8X4f2lnq 的评论
助手:调用脚本(自动生成HTML) → 展示全部评论 + AI总结 → 询问是否需要HTML → 用户确认 → backfill → open
Example 2: Query by opusId
用户:R8X4f2lnq 这篇博文的评论怎么样
助手:提取 opusId → 调用脚本 → 展示分析 → 询问是否需要HTML
Example 3: Pagination
用户:下一页
助手:调用脚本 page=2 cursor=xxx → 展示第2页 + AI累计分析 → 询问是否需要当前页HTML