193 lines
3.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 小红书笔记发布工具 - 使用说明
## 🎯 这是什么?
一个**超级简单**的小红书自动发布工具!
只需几行代码,就能自动发布图文/视频笔记到小红书 📱✨
## ⚡ 快速开始3步搞定
### 第1步安装
```bash
pip install playwright loguru
playwright install chromium
```
### 第2步准备你的图片
把图片放到任意文件夹,比如 `my_photos` 文件夹
### 第3步写代码发布
创建 `发布笔记.py`
```python
import asyncio
from publisher import XiaoHongShuImageNote
async def main():
note = XiaoHongShuImageNote(
title="我的第一篇笔记", # 标题
content="Hello 小红书!", # 正文
tags=["#新人"], # 标签
image_paths=["my_photos/1.jpg"], # 图片路径
publish_date=0, # 0=立即发布
account_file="cookies/my.json" # Cookie保存位置
)
await note.main()
print("发布成功!")
asyncio.run(main())
```
运行:
```bash
python 发布笔记.py
```
**首次运行会弹出浏览器用小红书App扫码登录即可**
## 📸 常用功能
### 1⃣ 发布多张图片
```python
image_paths=["1.jpg", "2.jpg", "3.jpg"] # 最多9张
```
### 2⃣ 添加多个标签
```python
tags=["#美食", "#探店", "#广州"] # 最多3个
```
### 3⃣ 定时发布
```python
from datetime import datetime, timedelta
明天下午3点 = datetime.now() + timedelta(days=1)
明天下午3点 = 明天下午3点.replace(hour=15, minute=0)
note = XiaoHongShuImageNote(
...,
publish_date=明天下午3点 # 定时发布
)
```
### 4⃣ 添加位置
```python
location="广州塔" # 添加地理位置
```
### 5⃣ 发布视频
```python
from publisher import XiaoHongShuVideoNote
note = XiaoHongShuVideoNote(
title="我的vlog",
content="今天的记录",
tags=["#vlog"],
video_path="my_video.mp4", # 视频文件
publish_date=0,
account_file="cookies/my.json"
)
```
## 📚 示例文件
项目里有很多示例,直接运行就能看效果:
| 文件 | 说明 | 运行方式 |
|------|------|----------|
| `quick_test.py` | 快速测试 | `python quick_test.py` |
| `example_image.py` | 图文笔记示例 | `python example_image.py` |
| `example_video.py` | 视频笔记示例 | `python example_video.py` |
| `example_batch.py` | 批量发布示例 | `python example_batch.py` |
## ❓ 常见问题
### Q1: Cookie失效了怎么办
**A:** 删除Cookie文件重新运行会自动让你登录
```bash
rm cookies/my.json
python 发布笔记.py
```
### Q2: 为什么上传失败?
**A:** 检查这几点:
- ✅ 网络连接正常吗?
- ✅ 图片/视频文件存在吗?
- ✅ 文件路径写对了吗?
- ✅ 图片格式是jpg/png吗
### Q3: 可以批量发布吗?
**A:** 可以!参考 `example_batch.py`
### Q4: 支持多账号吗?
**A:** 支持每个账号用不同的Cookie文件
```python
# 账号1
account_file="cookies/账号1.json"
# 账号2
account_file="cookies/账号2.json"
```
### Q5: 会被封号吗?
**A:** 工具模拟真人操作,很安全。但要注意:
- ⚠️ 不要频繁发布建议间隔30秒以上
- ⚠️ 不要发布违规内容
- ⚠️ 不要一次发太多建议每天10篇以内
## 💡 使用技巧
### 技巧1批量发布要间隔
```python
# 发布完一篇后等30秒
await asyncio.sleep(30)
# 再发布下一篇
```
### 技巧2可以看到操作过程
```python
headless=False # 会打开浏览器,可以看到操作
```
### 技巧3指定封面图
```python
image_paths=["1.jpg", "2.jpg", "3.jpg"],
cover_index=1 # 使用第2张图作为封面从0开始数
```
## 📞 需要帮助?
- 📖 详细文档:`README.md`
- 🚀 快速指南:`QUICKSTART.md`
- 💬 遇到问题提Issue
## 🎉 开始使用吧!
运行快速测试体验一下:
```bash
python quick_test.py
```
**祝你使用愉快!**