157 lines
4.4 KiB
Markdown
157 lines
4.4 KiB
Markdown
# 小红书集成技能
|
|
|
|
## 功能概述
|
|
将IT资讯自动化系统与小红书平台集成,实现技术资讯的多渠道发布。
|
|
|
|
## 核心功能
|
|
1. **内容转换**:将技术文章转换为小红书格式
|
|
2. **图片处理**:优化图片以适应小红书平台
|
|
3. **发布管理**:管理小红书内容发布
|
|
4. **监控日志**:记录发布状态和结果
|
|
|
|
## 文件结构
|
|
```
|
|
xiaohongshu_integration/
|
|
├── SKILL.md # 技能说明文档
|
|
├── xiaohongshu_publisher.py # 小红书发布器
|
|
├── content_converter.py # 内容格式转换器
|
|
├── image_processor.py # 图片处理器
|
|
├── config.json # 配置文件模板
|
|
├── test_integration.py # 测试脚本
|
|
└── nanobot_integration.py # nanobot集成接口
|
|
```
|
|
|
|
## 使用方法
|
|
|
|
### 1. 基本使用
|
|
```python
|
|
from xiaohongshu_publisher import XiaohongshuPublisher
|
|
from content_converter import ContentConverter
|
|
|
|
# 初始化
|
|
publisher = XiaohongshuPublisher(config_path='config.json')
|
|
converter = ContentConverter()
|
|
|
|
# 转换内容
|
|
article = {
|
|
'title': 'AI技术新突破',
|
|
'content': 'OpenAI发布最新模型...',
|
|
'source': 'TechCrunch',
|
|
'images': ['image1.jpg', 'image2.jpg']
|
|
}
|
|
|
|
xhs_content = converter.to_xiaohongshu(article)
|
|
|
|
# 发布
|
|
result = publisher.publish(
|
|
title=article['title'],
|
|
content=xhs_content,
|
|
images=article['images']
|
|
)
|
|
```
|
|
|
|
### 2. 集成到IT资讯系统
|
|
```python
|
|
from enhanced_web_fetcher import EnhancedWebFetcher
|
|
from xiaohongshu_integration import XiaohongshuIntegration
|
|
|
|
# 创建集成系统
|
|
system = XiaohongshuIntegration()
|
|
|
|
# 处理URL
|
|
url = 'https://techcrunch.com/latest'
|
|
success = system.process_and_publish(url)
|
|
|
|
if success:
|
|
print('✅ 文章已发布到小红书')
|
|
else:
|
|
print('❌ 发布失败')
|
|
```
|
|
|
|
## 配置说明
|
|
|
|
### 配置文件 (config.json)
|
|
```json
|
|
{
|
|
"xiaohongshu": {
|
|
"enabled": true,
|
|
"cli_path": "/path/to/xhs-cli",
|
|
"username": "your_username",
|
|
"password": "your_password",
|
|
"max_images": 9,
|
|
"add_watermark": true,
|
|
"watermark_text": "技术资讯",
|
|
"default_tags": ["#技术资讯", "#科技新闻", "#AI"],
|
|
"publish_interval": 3600
|
|
},
|
|
"content": {
|
|
"max_title_length": 30,
|
|
"max_content_length": 1000,
|
|
"auto_generate_tags": true,
|
|
"add_source_info": true
|
|
},
|
|
"images": {
|
|
"max_width": 1080,
|
|
"max_height": 1920,
|
|
"quality": 85,
|
|
"format": "JPEG"
|
|
}
|
|
}
|
|
```
|
|
|
|
## 依赖要求
|
|
- Python 3.8+
|
|
- Pillow (图片处理)
|
|
- 小红书CLI工具(需要手动安装)
|
|
|
|
## 安装步骤
|
|
1. 复制本技能到nanobot技能目录
|
|
2. 安装依赖:`pip install pillow`
|
|
3. 配置小红书CLI工具
|
|
4. 修改配置文件
|
|
5. 运行测试:`python test_integration.py`
|
|
|
|
## 注意事项
|
|
1. 小红书有发布频率限制,请合理设置间隔
|
|
2. 内容需遵守小红书社区规范
|
|
3. 建议先使用测试账号进行测试
|
|
4. 定期检查发布状态,避免账号异常
|
|
|
|
## 故障排除
|
|
- **CLI不可用**:检查路径配置和权限
|
|
- **登录失败**:验证账号密码,检查网络
|
|
- **发布失败**:查看错误日志,调整内容格式
|
|
- **图片问题**:检查图片格式和大小限制
|
|
|
|
## 增强版功能 (2026-04-03新增)
|
|
|
|
### 图片风格生成集成
|
|
- **智能内容分析**: 自动分析内容类型,推荐最佳图片风格
|
|
- **AI图片生成**: 集成豆包Seedream API,生成小红书风格配图
|
|
- **多种风格支持**: 8种风格 × 6种布局组合
|
|
- **预设系统**: 6种常用预设,一键生成
|
|
- **批量处理**: 支持批量处理多个Markdown文件
|
|
|
|
### 增强版工具
|
|
- `xiaohongshu_enhanced_publisher.py` - 增强版发布器(集成图片生成)
|
|
- `xiaohongshu_enhanced_config.json` - 增强版配置文件
|
|
- `ENHANCED_GUIDE.md` - 增强版使用指南
|
|
- `integration_example.py` - 集成示例代码
|
|
|
|
### 快速使用
|
|
```bash
|
|
# 使用增强版发布器(自动生成图片)
|
|
python3 xiaohongshu_enhanced_publisher.py publish --markdown article.md
|
|
|
|
# 指定风格和布局
|
|
python3 xiaohongshu_enhanced_publisher.py publish --markdown article.md --style notion --layout dense
|
|
|
|
# 批量处理
|
|
python3 xiaohongshu_enhanced_publisher.py batch --directory ./articles/
|
|
```
|
|
|
|
## 更新日志
|
|
- v1.0.0: 初始版本,支持基本发布功能
|
|
- v1.1.0: 添加内容转换和图片处理
|
|
- v1.2.0: 集成到IT资讯自动化系统
|
|
- v2.0.0: 🆕 增强版,集成图片风格生成功能 (2026-04-03) |