SuperAPI AI Directory

xiaohongshu-comment

Data & analytics

View repository

Updated 10-16 11:06

About this skill

Xiaohongshu Comment Analysis

📝 Introduction

Enter a Xiaohongshu note link to retrieve first-level comment data, 20 per page, with cursor-based pagination supported. Display all comments on the current page along with AI summary analysis in the conversation, and simultaneously generate an interactive HTML report containing the current page data and summary.

✨ Features

Feature Module Capability Description Core Value
Comment Retrieval Paste a note link to retrieve comments Real-time retrieval of note comment section data
Paginated Browsing 20 per page, cursor-based pagination Browse large numbers of comments page by page
AI Summary Four-dimensional sentiment analysis (positive/negative/demand/competitor) Quickly understand the full picture of comment public opinion
Pinned Marking Special marking for pinned comments Identify important comments at a glance
HTML Report Dark-themed interactive report Save/share analysis results offline

🔑 Authentication

  • Get API Key: Go to Honghu hub
  • Configuration method 1: Write to ~/.openclaw/openclaw.json → { "env": { "REDFOX_API_KEY": "ak_xxxx..." } }
  • Configuration method 2: Execute in terminal export REDFOX_API_KEY="ak_xxxx..."

🔄 Workflow

Step 1: Understand user intent, extract noteId

⚠️ Core rule: The user provides a note link, and the Agent extracts the noteId from the link.

  • The user provides a note link (e.g., https://www.xiaohongshu.com/explore/6a2ac3020000000035022d8e), and the Agent extracts the noteId from the link
  • The user may also directly provide a noteId (e.g., 6a2ac3020000000035022d8e), in which case use it directly
  • If the user does not provide a note link, proactively ask: "Please provide a Xiaohongshu note link"
  • If the user queried data for a certain note in the previous round of conversation and the current input is ambiguous (such as "next page" or "comment analysis"), reuse the noteId from the previous round

Step 2: Call the comment retrieval script (automatically generates HTML)

⚠️ Each call requests only one page of data (one API request); do not initiate multiple calls to retrieve multiple pages without authorization.

The script automatically generates an HTML report on each call(containing {{PLACEHOLDER}} placeholders, with analysis data not yet filled in). The terminal display and HTML are based onthe same API call, ensuring data consistency.

python3 ~/.agents/skills/xiaohongshu-comment/scripts/xiaohongshu_comment_search.py "<noteId>" [--cursor <cursor>] [--page <page>]

Parameter description:

Parameter Description Default Value
noteId Xiaohongshu note noteId (required) —
--cursor Cursor; pass an empty string for the first page "", and pass the value returned by the previous page for the next page nextCursor ""
--page Current page number (only used for the HTML file name and output marker) 1
--output-dir HTML output directory ~/Downloads/QoderReports

Correspondence between cursor and page number:

Page Number cursor
Page 1 ""(empty string)
Page 2 Returned by page 1 nextCursor
Page 3 Returned by page 2 nextCursor
... Returned by the previous page nextCursor

Script returns JSON:

Field Description
note_id Note ID
current_page Current page number
cursor Cursor used for this request
next_cursor Cursor for the next page (valid when has_next is true)
total_fetched Number of comments fetched this time
has_next Whether there is a next page (true/false)
comments Comment list
html_path Path of the generated HTML report (contains placeholders, to be filled in)

Fields for each comment:

Field Description
comment_id Comment ID
content Comment content
like_count Number of likes
reply_count Number of replies
create_time Comment time
ip_location IP location
user_name User nickname
user_avatar User avatar URL
user_id User ID (used to generate the profile link)
user_url User profile link
is_top Whether pinned (true/false)

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: Display comment data + AI summary in the conversation

⚠️ Each operation calls the API only once to fetch one page of data. The conversation display and the HTML report are based on the same page of data.

A1. State the query scope

📊 Note "{noteId}" fetched a total of Ncomments (page {page}), the detailed data is as follows:

A2. Render the comment table (display all comments on the current page)

| # | 评论人 | 评论内容 | 👍 | 💬 | 时间 | IP |
|---|--------|---------|----|----|------|-----|
| 1 | ![avatar](头像URL)[昵称](主页链接) | 评论内容... | 1223 | 213 | 02-12 15:30 | 广东 |
| 2 | ![avatar](头像URL)[昵称](主页链接) | 评论内容... | 856 | 45 | 02-12 14:20 | 北京 |
| ... | ... | ... | ... | ... | ... | ... |

Format rules:

  • The commenter column uses ![avatar](头像URL)[昵称](user_url) Markdown format, no image size needs to be set
  • Comment content exceeding 40 characters is truncated with ...
  • Time is formatted as MM-DD HH:MM
  • Pinned comments have 📌 added after the nickname (the entire comment row uses bold style)
  • like_count / reply_count Numbers ≥ 10000 use the x.xw format
  • ⚠️ A maximum of 20 comments per page; display all of them in the conversation, do not truncate

A3. AI comment summary (⚠️ must be output for every query (including pagination))

Based on all comments fetched from the current page, perform a four-dimensional sentiment analysis.Before analysis, it is necessary to understand Xiaohongshu community culture(slang, emoji semantics, platform-specific expressions).

📈 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 sentiment ({competitor_ratio}%)

  • {output only when competitors are mentioned in the comments, otherwise output "no competitors mentioned"}
  • {competitor name}: {sentiment point}

Analysis requirements:

  • Each key point must cite representative comments (excerpt keywords/phrases)
  • The percentage is the proportion of the number of comments mentioning that type 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 Xiaohongshu community culture: recognize platform buzzwords, emoji semantics, seeding/unseeding (grass-planting/grass-pulling) context, and the meanings of unique expressions such as "绝绝子", "yyds", "码住"

A4. Pagination prompt (⚠️ immediately after A3, must be output every time)

  • If has_next is true:

📄 Current page {page} (total {total_fetched} items). Reply "next page" to continue viewing.

  • If has_next is false:

📄 Current page {page} , no more data.

⚠️ A1~A4 must be completed consecutively in the same round of output; no step may be omitted.

After A4 output is complete,ask the user whether they need to generate an HTML visualization report:

📊 Do you need to generate an HTML visualization report?

If the user replies with confirmation words such as "yes", "need", "generate", "html", 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/xiaohongshu-comment/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>"

Step 4: Pagination handling (when the user replies "next page", etc.)

When the user replies "next page", "previous page", "page N":

  1. Use the noteId extracted in Step 1
  2. Get the nextCursor returned by the previous page as the new cursor value (or fall back to the previous page's cursor)
  3. Call the script again (same as Step 2, automatically generate HTML):python3 ~/.agents/skills/xiaohongshu-comment/scripts/xiaohongshu_comment_search.py "<noteId>" --cursor "<nextCursor>" --page <page>
  4. Fully execute A1~A4 of Step 3(independent display per page + AI analysis)
  5. After A4, ask the user whether they need to generate the HTML for the current page (same as the process at the end of Step 3,no need to call the script again)

Pagination rules:

  • has_next is true → the current page has a next page, use nextCursor to paginate
  • has_next is false → the current page is already the last page
  • ⚠️ Important: the cursor value must be passed as-is and must not be modified or concatenated

Step 5: Error Handling

Error Type Handling Method
No API Key Prompt to configure REDFOX_API_KEY, provide configuration guidance
Invalid note link Prompt "No comments found for this note, please check whether the note link is correct"
API returned an error Display error code and error message
Retrieved 0 comments Prompt "This note has no comments yet" and suggest checking whether the note exists or has been deleted
Network request timeout Prompt "Network request timed out, please try again later"

📋 Dependencies

# 脚本使用 urllib(Python 标准库),无需额外安装依赖

🎯 Usage Examples

Example 1: View comments of a specified note

用户:查看小红书笔记 6a2ac3020000000035022d8e 的评论
助手:调用脚本(自动生成HTML) → 展示全部20条 + AI总结 → 询问是否需要HTML → 用户确认 → backfill → open

Example 2: Query via link

用户:https://www.xiaohongshu.com/explore/6a2ac3020000000035022d8e 这篇的评论怎么样
助手:提取 noteId → 调用脚本 → 展示分析 → 询问是否需要HTML

Example 3: Pagination

用户:下一页
助手:调用脚本 cursor=<上一页nextCursor> → 展示第2页 + AI分析 → 询问是否需要当前页HTML