Files
Auto-Redbook-Skills/README.md
ZhangJia 04a17ed78a feat: v2.0 智能分页渲染 + 7种可选样式
新增功能:
- 智能分页渲染脚本(Python/Node.js),自动解决内容溢出问题
- 7种可选样式主题:purple, xiaohongshu, mint, sunset, ocean, elegant, dark
- 新增 STYLES.md 样式选择指南
- 更新 README,添加 v2.0 更新说明
- 保留 V1 旧版脚本保证兼容性

使用方式:
  python scripts/render_xhs_v2.py note.md --style sunset
2026-01-26 15:48:30 +08:00

6.6 KiB
Raw Blame History

📕 Auto-Redbook-Skills

一个自动撰写笔记、生成图片、自动发布小红书的 Skills

Python Node.js License


🆕 v2.0 版本更新

新增功能

  • 🚀 智能分页渲染 - 自动检测内容高度,超出时自动拆分到多张卡片,彻底解决文字溢出问题
  • 🎨 7种可选样式 - 新增多种主题风格,一键切换不同视觉效果
  • V2 渲染脚本 - 全新 render_xhs_v2.py / render_xhs_v2.js,推荐升级使用

📋 可用样式列表

样式 名称 预览
purple 紫韵(默认) 蓝紫色渐变
xiaohongshu 小红书红 品牌红色系
mint 清新薄荷 绿色自然调
sunset 日落橙 粉橙浪漫调
ocean 深海蓝 海洋蓝色调
elegant 优雅白 灰白简约调
dark 暗黑模式 深色高对比

🎯 使用 V2 脚本

# Python 版本
python scripts/render_xhs_v2.py note.md --style sunset

# Node.js 版本
node scripts/render_xhs_v2.js note.md --style ocean

# 查看所有样式
python scripts/render_xhs_v2.py --list-styles

📁 v2.0 新增文件

scripts/
├── render_xhs_v2.py    # 新增Python 智能分页版(推荐)
├── render_xhs_v2.js    # 新增Node.js 智能分页版(推荐)
├── render_xhs.py       # 旧版:保留兼容
└── render_xhs.js       # 旧版:保留兼容
STYLES.md               # 新增:样式选择指南

V1 旧版脚本保留兼容V2 版本完全向下兼容 Markdown 格式。


功能特性

  • 📝 撰写笔记 - 根据既定主题,撰写小红书笔记(提示词自己调整,在 SKILL.md里)
  • 🎨 生成卡片 - 根据内容自动渲染生成图片,包含 cover 和内容详情,支持 Markdown 渲染
  • 🐍 双语言脚本 - 提供 Python 和 Node.js 两种渲染方案
  • 📤 一键发布 - 支持直接发布到小红书(需配置 Cookie

🚀 快速开始

Clone 项目

Clone 项目到本地


git clone https://github.com/comeonzhj/Auto-Redbook-Skills.git					 

移动到支持 Skills 的客户端对应文件夹里:

  • For Claude ~/.claude/skills/
  • For Alma ~/.config/Alma/skills/
  • For TRAE /your-path/.trae/skills/

安装依赖

Python 版本:

pip install markdown pyyaml playwright python-dotenv xhs
playwright install chromium

Node.js 版本:

cd Auto-Redbook-Skills
npm install
npx playwright install chromium

🎨 渲染图片

V2 渲染(推荐)

# 使用默认样式
python scripts/render_xhs_v2.py note.md

# 指定样式主题
python scripts/render_xhs_v2.py note.md --style sunset

# 指定输出目录
python scripts/render_xhs_v2.py note.md -o ./output --style xiaohongshu

# 查看所有样式
python scripts/render_xhs_v2.py --list-styles

V2 特性:

  • 智能分页:自动检测内容高度,自动拆分卡片
  • 固定尺寸:所有卡片固定 1080×1440px
  • 多种样式7种预设主题风格

V1 渲染(旧版)

# Python 版本
python scripts/render_xhs.py note.md

# Node.js 版本
node scripts/render_xhs.js note.md

注意: V1 版本当内容过长时可能出现溢出,建议手动使用 --- 分隔内容。

📤 发布到小红书

复制 env.example.txt.env,填入小红书 Cookie

cp env.example.txt .env

编辑 .env 文件:

XHS_COOKIE=your_cookie_string_here

获取 Cookie 方法:

  1. 在浏览器中登录 小红书
  2. 打开开发者工具F12
  3. 在 Network 标签中查看任意请求的 Cookie 头
  4. 复制完整的 cookie 字符串

2. 发布笔记

Skills 会自动发布,也可以手动执行:

python scripts/publish_xhs.py \
  --title "笔记标题" \
  --desc "笔记描述内容" \
  --images cover.png card_1.png card_2.png

可选参数:

参数 说明
--private 设为私密笔记
--post-time "2024-01-01 12:00:00" 定时发布
--dry-run 仅验证,不实际发布

🎨 自定义样式

修改背景渐变V1

编辑 assets/card.html 中的 .card-container

.card-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

预设渐变色:

名称 渐变值
紫蓝 #667eea → #764ba2
粉红 #f093fb → #f5576c
青蓝 #4facfe → #00f2fe
绿色 #43e97b → #38f9d7
橙黄 #fa709a → #fee140

更多样式选择V2

V2 版本提供 7 种内置样式,通过 --style 参数快速切换:

python scripts/render_xhs_v2.py note.md --style dark   # 暗黑模式
python scripts/render_xhs_v2.py note.md --style mint   # 清新薄荷

详见 STYLES.md

📁 项目结构

md2Redbook/
├── SKILL.md              # 技能描述AI Agent 使用)
├── README.md             # 项目文档
├── STYLES.md             # 样式选择指南
├── requirements.txt      # Python 依赖
├── package.json          # Node.js 依赖
├── env.example.txt       # Cookie 配置示例
├── assets/
│   ├── cover.html        # 封面 HTML 模板
│   ├── card.html         # 正文卡片 HTML 模板
│   ├── styles.css        # 共用样式表
│   └── example.md        # 示例 Markdown
└── scripts/
    ├── render_xhs_v2.py  # Python 渲染脚本 V2推荐
    ├── render_xhs_v2.js  # Node.js 渲染脚本 V2推荐
    ├── render_xhs.py     # Python 渲染脚本 V1
    ├── render_xhs.js     # Node.js 渲染脚本 V1
    └── publish_xhs.py    # 小红书发布脚本

⚠️ 注意事项

  1. Cookie 安全 - Cookie 包含登录凭证,请勿泄露或提交到版本控制
  2. Cookie 有效期 - 小红书 Cookie 会过期,需定期更新
  3. 发布频率 - 避免频繁发布,以免触发平台限制
  4. 图片尺寸 - 渲染的图片为 1080×1440px符合小红书推荐比例

🙏 致谢

📄 License

MIT License © 2026