rednote-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rednote Skill

Rednote Skill

This skill allows you to fully interact with the Xiaohongshu (Little Red Book) platform. You can search for posts by keyword and return results, extract content from specific notes to structured markdown format, and perform engagement actions like liking, commenting, collecting, following users, and more.
该Skill可让你与Xiaohongshu(小红书)平台进行完整交互。你可以按关键词搜索帖子并返回结果,将特定笔记的内容提取为结构化的markdown格式,还可执行点赞、评论、收藏、关注用户等互动操作。

Configuration and Preparation

配置与准备

Requirements

依赖要求

  • Python 3.7+
  • Playwright (install with
    pip install playwright
    )
  • Playwright drivers (install with
    playwright install
    )
  • Configured browser environment
  • Python 3.7+
  • Playwright(使用
    pip install playwright
    安装)
  • Playwright驱动(使用
    playwright install
    安装)
  • 已配置好的浏览器环境

Always DO FIRST

请务必先执行以下操作

Before using this skill, the system will verify your login status:
python scripts/validate_cookies.py
If the output is
True
, you have normal access and can proceed with search operations.
If the output is
False
or the login button is visible, the system will automatically execute the manual login procedure:
python scripts/manual_login.py
The system will launch the login interface in a browser window. You'll need to follow the instructions in the opened browser to complete the login process manually, then close the browser after completion.
使用该Skill前,系统会验证你的登录状态:
python scripts/validate_cookies.py
如果输出为
True
,说明你拥有正常访问权限,可以继续执行搜索操作。
如果输出为
False
或页面显示登录按钮,系统会自动执行手动登录流程:
python scripts/manual_login.py
系统会在浏览器窗口中打开登录界面,你需要按照打开的浏览器中的提示手动完成登录流程,完成后关闭浏览器即可。

Usage Steps

使用步骤

1. Environment Setup

1. 环境搭建

Before using this skill, ensure that:
  1. The required dependencies are installed (Python 3.7+, Playwright)
  2. The system will automatically handle the cookie saving via the manual login process when needed
  3. Login status will be validated automatically using the validation utility
使用该Skill前,请确保:
  1. 已安装所需依赖(Python 3.7+、Playwright)
  2. 需要时系统会通过手动登录流程自动处理Cookie保存
  3. 系统会使用验证工具自动校验登录状态

2. Using Search Functions

2. 使用搜索功能

The skill provides several search and extraction functions:
  • Search Notes by Keyword:
    python scripts/search_note_by_key_word.py <KEYWORD> [--top_n TOP_N]
  • Extract Note Content:
    python scripts/dump_note.py <NOTE_URL>
该Skill提供多种搜索和提取功能:
  • 按关键词搜索笔记:
    python scripts/search_note_by_key_word.py <KEYWORD> [--top_n TOP_N]
  • 提取笔记内容:
    python scripts/dump_note.py <NOTE_URL>

3. Using Interaction Functions

3. 使用交互功能

The skill provides several interaction functions:
  • Like Note:
    python scripts/like_note.py <NOTE_URL>
  • Collect Note:
    python scripts/collect_note.py <NOTE_URL>
  • Comment on Note:
    python scripts/comment_note.py <NOTE_URL> <COMMENT_TEXT>
  • Follow User:
    python scripts/follow_user.py <NOTE_URL>
  • Publish Note:
    python scripts/publish_note.py --image-urls <IMG1 [IMG2 ...]> --title <TITLE> --content <CONTENT> --tags <TAG1 [TAG2 ...]>
  • Validate Login:
    python scripts/validate_cookies.py
  • Manual Login:
    python scripts/manual_login.py
该Skill提供多种交互功能:
  • 点赞笔记:
    python scripts/like_note.py <NOTE_URL>
  • 收藏笔记:
    python scripts/collect_note.py <NOTE_URL>
  • 评论笔记:
    python scripts/comment_note.py <NOTE_URL> <COMMENT_TEXT>
  • 关注用户:
    python scripts/follow_user.py <NOTE_URL>
  • 发布笔记:
    python scripts/publish_note.py --image-urls <IMG1 [IMG2 ...]> --title <TITLE> --content <CONTENT> --tags <TAG1 [TAG2 ...]>
  • 验证登录状态:
    python scripts/validate_cookies.py
  • 手动登录:
    python scripts/manual_login.py

4. Complete Workflow

4. 完整工作流

  1. Validate login status before starting interactions
  2. Execute desired search functions if you need to find specific notes
  3. Execute desired interaction functions with proper arguments
  4. Monitor results for successful completion
  1. 开始交互前验证登录状态
  2. 如果需要查找特定笔记,执行所需的搜索功能
  3. 传入正确参数执行所需的交互功能
  4. 监控结果确认操作成功完成

Function Descriptions

功能说明

This skill provides the following functions for searching content on and interacting with the Xiaohongshu platform:
该Skill提供以下功能,用于在小红书平台搜索内容和进行交互:

Search Notes (
search_note_by_key_word.py
)

搜索笔记 (
search_note_by_key_word.py
)

Purpose: Searches for Xiaohongshu notes using the provided keyword.
Parameters:
  • keyword
    (string): The keyword to search for
  • --top_n
    (integer, optional): Number of return notes (default is 5)
Returns: List of note URLs that match the keyword
Behavior: Launches browser, searches for the keyword on Xiaohongshu, returns matching note URLs.
用途: 使用提供的关键词搜索小红书笔记。
参数:
  • keyword
    (字符串): 要搜索的关键词
  • --top_n
    (整数,可选): 返回的笔记数量(默认值为5)
返回: 匹配关键词的笔记URL列表
行为: 启动浏览器,在小红书搜索关键词,返回匹配的笔记URL。

Extract Note Content (
dump_note.py
)

提取笔记内容 (
dump_note.py
)

Purpose: Extracts specific note content and converts to formatted markdown.
Parameters:
  • note_url
    (string): The URL of the note to extract content from
Returns: Structured markdown content including author, title, media, description, tags, and interaction data
Behavior: Launches browser, accesses the note, extracts content and formats to markdown.
用途: 提取特定笔记的内容并转换为格式化的markdown。
参数:
  • note_url
    (字符串): 要提取内容的笔记URL
返回: 结构化的markdown内容,包含作者、标题、媒体资源、描述、标签和交互数据
行为: 启动浏览器,访问笔记页面,提取内容并格式化为markdown。

Like Note (
like_note.py
)

点赞笔记 (
like_note.py
)

Purpose: Likes a specific note on Xiaohongshu using the note URL.
Parameters:
  • note_url
    (string): The URL of the note to like
Returns: Success or error message indicating if the like was successful
Behavior: Launches browser, navigates to the note URL, clicks the like button, then closes the browser.
用途: 使用笔记URL为小红书上的特定笔记点赞。
参数:
  • note_url
    (字符串): 要点赞的笔记URL
返回: 指示点赞是否成功的成功或错误消息
行为: 启动浏览器,导航到笔记URL,点击点赞按钮,然后关闭浏览器。

Collect Note (
collect_note.py
)

收藏笔记 (
collect_note.py
)

Purpose: Collects (saves) a specific note to the user's collection.
Parameters:
  • note_url
    (string): The URL of the note to collect
Returns: Success or error message indicating if the collection was successful
Behavior: Launches browser, navigates to the note URL, clicks the collect button, then closes the browser.
用途: 将特定笔记收藏(保存)到用户的收藏夹中。
参数:
  • note_url
    (字符串): 要收藏的笔记URL
返回: 指示收藏是否成功的成功或错误消息
行为: 启动浏览器,导航到笔记URL,点击收藏按钮,然后关闭浏览器。

Comment on Note (
comment_note.py
)

评论笔记 (
comment_note.py
)

Purpose: Adds a comment to a specific note on Xiaohongshu.
Parameters:
  • note_url
    (string): The URL of the note to comment on
  • comment_text
    (string): The text content of the comment
Returns: Success or error message indicating if the comment was published
Behavior: Launches browser, navigates to the note URL, fills in the comment text, clicks the send button, then closes the browser.
用途: 为小红书上的特定笔记添加评论。
参数:
  • note_url
    (字符串): 要评论的笔记URL
  • comment_text
    (字符串): 评论的文本内容
返回: 指示评论是否发布成功的成功或错误消息
行为: 启动浏览器,导航到笔记URL,填写评论文本,点击发送按钮,然后关闭浏览器。

Follow User (
follow_user.py
)

关注用户 (
follow_user.py
)

Purpose: Follows the user who created a specific note by visiting a note URL.
Parameters:
  • note_url
    (string): The URL of a note by the user to follow
Returns: Success or error message indicating if the follow action was successful
Behavior: Launches browser, navigates to the note URL, clicks the follow button if available, then closes the browser.
用途: 通过访问笔记URL关注发布该特定笔记的用户。
参数:
  • note_url
    (字符串): 要关注的用户发布的某条笔记的URL
返回: 指示关注操作是否成功的成功或错误消息
行为: 启动浏览器,导航到笔记URL,点击可用的关注按钮,然后关闭浏览器。

Validate Login Status (
validate_cookies.py
)

验证登录状态 (
validate_cookies.py
)

Purpose: Checks if the saved authentication tokens are valid and the user is logged in to Xiaohongshu.
Parameters: None
Returns: Boolean value indicating whether login is successful
Behavior: Launches browser, accesses Xiaohongshu homepage with stored credentials, checks for login state.
用途: 检查保存的身份验证令牌是否有效,以及用户是否已登录小红书。
参数: 无
返回: 指示登录是否成功的布尔值
行为: 启动浏览器,使用存储的凭证访问小红书首页,检查登录状态。

Manual Login (
manual_login.py
)

手动登录 (
manual_login.py
)

Purpose: Assists in creating valid authentication cookies by opening the login interface.
Parameters: None
Returns: Success or error message after cookies are saved
Behavior: Launches browser, navigates to Xiaohongshu, allows user to log in manually, then saves cookies to storage file.
用途: 通过打开登录界面协助生成有效的身份验证Cookie。
参数: 无
返回: Cookie保存后返回成功或错误消息
行为: 启动浏览器,导航到小红书,允许用户手动登录,然后将Cookie保存到存储文件。

Publish Note (
publish_note.py
)

发布笔记 (
publish_note.py
)

Purpose: Publishes a new image-text note to the user's Xiaohongshu account with provided content, images, and tags.
Parameters:
  • --image-urls IMG1 [IMG2 ...]
    : Paths to one or more image files to upload with the note (required)
  • --title TITLE
    : The title for the new note (required)
  • --content CONTENT
    : The main content text for the new note (required)
  • --tags TAG1 [TAG2 ...]
    : One or more tags to attach to the note (required)
Returns: Success or error message indicating if the note was published successfully
Behavior: Launches browser, navigates to the Xiaohongshu publish page, fills in the note title, content, tags and uploads provided images, then clicks the publish button.
用途: 使用提供的内容、图片和标签,向用户的小红书账号发布新的图文笔记。
参数:
  • --image-urls IMG1 [IMG2 ...]
    : 随笔记上传的一个或多个图片文件的路径(必填)
  • --title TITLE
    : 新笔记的标题(必填)
  • --content CONTENT
    : 新笔记的主要内容文本(必填)
  • --tags TAG1 [TAG2 ...]
    : 要附加到笔记的一个或多个标签(必填)
返回: 指示笔记是否发布成功的成功或错误消息
行为: 启动浏览器,导航到小红书发布页面,填写笔记标题、内容、标签,上传提供的图片,然后点击发布按钮。

Examples

示例

Basic Search and Content Extraction

基础搜索和内容提取

undefined
undefined

Validate login status

验证登录状态

python scripts/validate_cookies.py
python scripts/validate_cookies.py

Search for notes about "旅行攻略"

搜索关于"旅行攻略"的笔记

python scripts/search_note_by_key_word.py "旅行攻略" --top_n 3
python scripts/search_note_by_key_word.py "旅行攻略" --top_n 3

Extract content from a specific note

提取特定笔记的内容

undefined
undefined

Basic Liking and Collecting

基础点赞和收藏

undefined
undefined

Like a specific note

为特定笔记点赞

Collect a specific note

收藏特定笔记

python scripts/collect_note.py "https://www.xiaohongshu.com/explore/some-note-id"
undefined
python scripts/collect_note.py "https://www.xiaohongshu.com/explore/some-note-id"
undefined

Commenting on a Note

评论笔记

undefined
undefined

Add a comment to a specific note

为特定笔记添加评论

python scripts/comment_note.py "https://www.xiaohongshu.com/explore/some-note-id" "Beautiful content! Thanks for sharing."
undefined
python scripts/comment_note.py "https://www.xiaohongshu.com/explore/some-note-id" "Beautiful content! Thanks for sharing."
undefined

Following a User

关注用户

undefined
undefined

Follow a user based on one of their posts

根据用户的某条帖子关注该用户

undefined
undefined

Publishing a Note

发布笔记

undefined
undefined

Publish a new note with images, title, content, and tags

发布包含图片、标题、内容和标签的新笔记

python scripts/publish_note.py
--image-urls "/path/to/img1.jpg" "/path/to/img2.jpg"
--title "My New Post"
--content "Check out this amazing discovery!"
--tags "travel" "food" "lifestyle"
undefined
python scripts/publish_note.py
--image-urls "/path/to/img1.jpg" "/path/to/img2.jpg"
--title "My New Post"
--content "Check out this amazing discovery!"
--tags "travel" "food" "lifestyle"
undefined

Complete User Session

完整用户会话

undefined
undefined

1. Validate login

1. 验证登录状态

python scripts/validate_cookies.py
python scripts/validate_cookies.py

2. Search for interesting content

2. 搜索感兴趣的内容

python scripts/search_note_by_key_word.py "美食推荐" --top_n 5
python scripts/search_note_by_key_word.py "美食推荐" --top_n 5

3. Extract detailed content from a note

3. 提取某条笔记的详细内容

python scripts/dump_note.py "https://www.xiaohongshu.com/explore/note1"
python scripts/dump_note.py "https://www.xiaohongshu.com/explore/note1"

4. Like interesting content

4. 为感兴趣的内容点赞

python scripts/like_note.py "https://www.xiaohongshu.com/explore/note1"
python scripts/like_note.py "https://www.xiaohongshu.com/explore/note1"

5. Collect useful content

5. 收藏有用的内容

python scripts/collect_note.py "https://www.xiaohongshu.com/explore/note2"
python scripts/collect_note.py "https://www.xiaohongshu.com/explore/note2"

6. Engage with community

6. 与社区互动

python scripts/comment_note.py "https://www.xiaohongshu.com/explore/note3" "Awesome tutorial!"
python scripts/comment_note.py "https://www.xiaohongshu.com/explore/note3" "Awesome tutorial!"

7. Follow good content creators

7. 关注优质内容创作者

undefined
undefined

Implementation Guidelines

实现指南

Best Practices

最佳实践

  1. Validate Login First: Login status will be automatically checked using
    validate_cookies.py
    before performing any interactions to ensure smooth operations.
  2. Rate Limiting: To avoid account restrictions, implement appropriate delays between consecutive interactions. Avoid excessive rapid interactions.
  3. Error Handling: Check the return values from the functions to ensure operations were successful before proceeding to the next action.
  4. User Intent: Only engage with content that matches user interest and preferences. The skill should complement user decisions.
  5. Browser State Management: The scripts manage browser opening and closing, so ensure system resources are available for these operations.
  1. 先验证登录状态: 执行任何交互前,系统会使用
    validate_cookies.py
    自动检查登录状态,确保操作顺利进行。
  2. 速率限制: 为避免账号被限制,连续交互之间要设置适当的延迟,避免过多的快速交互。
  3. 错误处理: 执行下一个操作前,检查函数的返回值确保操作成功。
  4. 用户意图: 仅与符合用户兴趣和偏好的内容互动,该Skill应为用户决策提供辅助。
  5. 浏览器状态管理: 脚本会管理浏览器的打开和关闭,因此请确保系统有足够的资源支持这些操作。

Integration Considerations

集成注意事项

  1. Session Management: The skill maintains session state through cookies stored in
    rednote_cookies.json
    . Ensure this file is properly secured.
  2. Browser Automation: The skill uses headless browsers for automation. Ensure the system has a compatible browser environment set up.
  3. URL Format: The scripts expect properly formatted Xiaohongshu URLs. Ensure URLs are valid before passing to functions.
  4. Content Appropriateness: Integrate this skill in a way that ensures interactions are appropriate and align with platform terms of service.
  1. 会话管理: 该Skill通过存储在
    rednote_cookies.json
    中的Cookie维护会话状态,请确保该文件得到妥善保护。
  2. 浏览器自动化: 该Skill使用无头浏览器实现自动化,请确保系统已设置兼容的浏览器环境。
  3. URL格式: 脚本要求小红书URL格式正确,传递给函数前请确保URL有效。
  4. 内容合规性: 集成该Skill时要确保交互行为合规,符合平台服务条款。

Configuration and Preparation

配置与准备

Advanced Setup

高级设置

Cookie Management

Cookie管理

  • The skill stores authentication data in
    rednote_cookies.json
  • This file is created automatically during the manual login process
  • For security, protect this cookie file from unauthorized access
  • 该Skill将身份验证数据存储在
    rednote_cookies.json
  • 该文件会在手动登录过程中自动创建
  • 出于安全考虑,请保护该Cookie文件,避免未经授权的访问

Environment Variables

环境变量

  • No specific environment variables are required
  • The skill uses the default configuration files in the scripts directory
  • 不需要特定的环境变量
  • 该Skill使用scripts目录中的默认配置文件

Prerequisites Verification

前置条件验证

Before using the rednote skill, verify:
  1. System Setup:
    • Python 3.7 or above
    • Playwright installed (
      pip install playwright
      )
    • Browser drivers installed (
      playwright install
      )
    • Minimum available disk space for browser operation
  2. Xiaohongshu Access:
    • Ability to access Xiaohongshu.com from your network
    • Compliance with Xiaohongshu's terms of service
    • Valid Xiaohongshu account credentials
  3. Security Setup:
    • The system will handle automatic login when needed
    • Login status will be confirmed via validation script
    • Secured storage for authentication tokens
使用rednote skill前,请验证:
  1. 系统设置:
    • Python 3.7或更高版本
    • 已安装Playwright (
      pip install playwright
      )
    • 已安装浏览器驱动 (
      playwright install
      )
    • 有足够的可用磁盘空间支持浏览器运行
  2. 小红书访问权限:
    • 网络可访问Xiaohongshu.com
    • 遵守小红书的服务条款
    • 有效的小红书账号凭证
  3. 安全设置:
    • 需要时系统会处理自动登录
    • 登录状态会通过验证脚本确认
    • 身份验证令牌的存储是安全的

Troubleshooting

故障排查

Common Issues

常见问题

Login Error (
❌ 未找到 cookies 文件,请先登录小红书并保存 cookies
)

登录错误 (
❌ 未找到 cookies 文件,请先登录小红书并保存 cookies
)

Cause: The
rednote_cookies.json
file doesn't exist or is not in the correct location. Solution: The system will automatically execute
python scripts/manual_login.py
to perform manual login and save cookies. The user just needs to complete the login process in the opened browser window.
原因:
rednote_cookies.json
文件不存在或路径不正确。 解决方案: 系统会自动执行
python scripts/manual_login.py
进行手动登录并保存Cookie,用户只需在打开的浏览器窗口中完成登录流程即可。

Login Session Expired (
❌ 未登录小红书,请先登录
)

登录会话过期 (
❌ 未登录小红书,请先登录
)

Cause: Authentication tokens have expired or are invalid. Solution: The system will re-verify login status and may execute
python scripts/manual_login.py
again to refresh tokens. The user just needs to complete the login process in the opened browser window if prompted.
原因: 身份验证令牌已过期或无效。 解决方案: 系统会重新验证登录状态,可能会再次执行
python scripts/manual_login.py
刷新令牌,如果出现提示,用户只需在打开的浏览器窗口中完成登录流程即可。

Page Navigation Issues

页面导航问题

Cause: Network connectivity issues or URL format errors. Solution: Verify URL format is correct, ensure internet connection is stable, and check if Xiaohongshu is accessible.
原因: 网络连接问题或URL格式错误。 解决方案: 验证URL格式正确,确保互联网连接稳定,检查是否可以访问小红书。

Element Not Found During Interaction

交互过程中找不到元素

Cause: Xiaohongshu's UI might have changed or the page hasn't loaded completely. Solution: Retry the operation; if the issue persists, check for interface changes or wait before trying again.
原因: 小红书的UI可能已更改,或者页面尚未完全加载。 解决方案: 重试操作;如果问题仍然存在,检查界面是否有更改,或等待一段时间后再重试。

Debugging Steps

调试步骤

  1. Verify Prerequisites: Ensure all requirements are installed and accessible
  2. Check Login Status: Run the validation script before operations
  3. Review URL Format: Ensure URLs are properly formatted Xiaohongshu links
  4. Monitor Browser Behavior: Use non-headless mode to observe the automation process
  5. Check Storage Files: Verify cookies file exists and is accessible
  1. 验证前置条件: 确保所有依赖都已安装且可访问
  2. 检查登录状态: 操作前运行验证脚本
  3. 检查URL格式: 确保URL是格式正确的小红书链接
  4. 监控浏览器行为: 使用非无头模式观察自动化过程
  5. 检查存储文件: 验证Cookie文件存在且可访问

Performance Considerations

性能注意事项

  • Browser automation is resource-intensive; ensure system has sufficient memory and CPU
  • Network latency may affect operation timing; consider adding delays between operations
  • Run validation scripts periodically to confirm stable authentication
  • 浏览器自动化占用资源较多,请确保系统有足够的内存和CPU
  • 网络延迟可能会影响操作时序,可以考虑在操作之间添加延迟
  • 定期运行验证脚本,确认身份验证状态稳定

Limitations and Considerations

限制与注意事项

Platform Limitations

平台限制

  • Terms of Service: This skill must be used in compliance with Xiaohongshu's terms of service and community guidelines
  • Rate Limiting: Xiaohongshu may impose limits on the number of interactions per time period
  • UI Changes: Xiaohongshu may update their interface, which could break element selectors used by the skill
  • Geographic Restrictions: Some functionality may be limited based on geographic location
  • 服务条款: 使用该Skill必须遵守小红书的服务条款和社区准则
  • 速率限制: 小红书可能会对特定时间段内的交互次数进行限制
  • UI更改: 小红书可能会更新界面,这可能会导致该Skill使用的元素选择器失效
  • 地域限制: 部分功能可能会因地理位置受到限制

Technical Limitations

技术限制

  • Browser Dependence: The skill relies on browser automation which may be slower than direct API calls
  • Stability: Browser automation can be affected by network conditions and site changes
  • Resource Usage: Each interaction launches a browser instance, consuming system resources
  • Headless Compatibility: Some interactions may work better in non-headless mode
  • 浏览器依赖: 该Skill依赖浏览器自动化,速度可能比直接调用API慢
  • 稳定性: 浏览器自动化可能会受到网络条件和站点更改的影响
  • 资源使用: 每次交互都会启动一个浏览器实例,消耗系统资源
  • 无头模式兼容性: 部分交互在非无头模式下可能效果更好

Security Considerations

安全注意事项

  • Authentication Storage: Authentication credentials are stored in
    rednote_cookies.json
    and should be secured
  • Privacy: Interactions performed with this skill will be visible to other users on Xiaohongshu
  • Data Handling: The skill doesn't collect user data beyond session management for interaction
  • 身份验证存储: 身份验证凭证存储在
    rednote_cookies.json
    中,应妥善保管
  • 隐私: 使用该Skill执行的交互对小红书上的其他用户可见
  • 数据处理: 除了用于交互的会话管理外,该Skill不会收集用户数据

Ethical Considerations

伦理注意事项

  • Authentic Engagement: Use the skill to facilitate genuine engagement with content that users actually find interesting
  • Respect Content Creators: Consider the impact of interactions on content creators and their audience
  • Anti-Spam Ethics: Avoid using the skill for spam-like behavior or in ways that could harm the platform ecosystem
  • 真实互动: 使用该Skill促进用户对真正感兴趣的内容进行真实互动
  • 尊重内容创作者: 考虑交互对内容创作者及其受众的影响
  • 反垃圾信息伦理: 避免将该Skill用于类似垃圾信息的行为,或可能损害平台生态的行为