Skip to content

chang-zy/xiaohongshu-skill

xiaohongshu-skills

Verified

小红书(RedNote / Xiaohongshu / XHS / RED / Little Red Book)浏览器自动化技能集合。 支持认证登录、内容发布、搜索发现、账号与评论分析、社交互动和复合运营。 当用户提到小红书、红书、RedNote、Xiaohongshu、XHS、RED、Little Red Book, 或要求发笔记、搜笔记、分析博主、评论、登录、点赞、收藏时触发。

scripts/xhs/cookies.py

View on GitHub
"""Cookie 文件持久化,对应 Go cookies/cookies.go。"""

from __future__ import annotations

import os
from pathlib import Path


def get_cookies_file_path(account: str = "") -> str:
    """获取 cookies 文件路径。

    优先级:
    1. /tmp/cookies.json(向后兼容)
    2. COOKIES_PATH 环境变量
    3. 多账号模式:~/.xhs/accounts/{account}/cookies.json
    4. ./cookies.json(本地调试)
    """
    if account:
        account_dir = Path.home() / ".xhs" / "accounts" / account
        account_dir.mkdir(parents=True, exist_ok=True)
        return str(account_dir / "cookies.json")

    # 旧路径
    import tempfile

    old_path = os.path.join(tempfile.gettempdir(), "cookies.json")
    if os.path.exists(old_path):
        return old_path

    # 环境变量
    env_path = os.getenv("COOKIES_PATH")
    if env_path:
        return env_path

    return "cookies.json"


def load_cookies(path: str) -> bytes | None:
    """从文件加载 cookies。"""
    try:
        with open(path, "rb") as f:
            return f.read()
    except FileNotFoundError:
        return None


def save_cookies(path: str, data: bytes) -> None:
    """保存 cookies 到文件。"""
    os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
    with open(path, "wb") as f:
        f.write(data)


def delete_cookies(path: str) -> None:
    """删除 cookies 文件。"""
    import contextlib

    with contextlib.suppress(FileNotFoundError):
        os.remove(path)
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall