Files
note2any/docs/xhspublisher.md
2025-10-09 12:39:24 +08:00

174 lines
6.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

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.

## 小红书自动化发布设计
### 需求
因为小红书发布的内容格式等限制,比如必须附加图片/视频title和content字数限制.....,需考虑:
1. markdown中的那些内容裁剪到小红书发布到小红书上的内容放在markdown文章内容可以是图片、文字、表格等任何markown元素段前:
```
<!--xhs-->
一段文字、一张图片或表格……
```
2. 内容实用css进行渲染后转化为图片渲染css作为主题可以自行定义。
另需考虑:
- 小红书登录需要能够记录cookie简化自动化登录过程。
- 自动化发布过程,应模拟用户参数(用户环境指纹等),规避平台拦截。
- 文章发布方式,参考公众号发布,右键点“发布到小红书”或者批量发布
4. 三类内容发布:
- 图文内容在小红书WEB版本上入口相同“上传图文”。
图文内容解析markdown中正文中的图片上传。
- 视频内容使用“上传视频”入口。视频从markdown正文中获取上传。
- 文字内容在小红书WEB版本上入口相同“上传图文”。
- 使用markdown header中的image tag定义的图片。
- 文字内容转化为图片
### 小红书CSS选择器
#### STEP 1
![[xhspublisher.png]]
**CSS选择器**
① div.publish-video .btn
② div.group-list .publish-card:nth-child(1) .image
③ div.group-list .publish-card:nth-child(2) .image
#### STEP 21 发布笔记
![[xhspublisher-2.png]]
**CSS选择器**
① div.publish-video .btn
② div.outarea.upload-c .creator-tab:nth-child(1)
③ div.outarea.upload-c .creator-tab:nth-child(3)
④ div.outarea.upload-c .upload-content button
#### STEP 22 上传视频
点击上传视频后( ② div.outarea.upload-c .creator-tab:nth-child(1) )
![[xhspublisher-3.png]]
![[xhspublisher-6.png]]
**CSS选择器**
① .cover-container .stage div:first-child
判断出现文字“上传成功”,**设计为异步等待?不阻塞标题及内容输入等其他操作。**
② .titleInput .d-text
③ #quillEditor.ql-editor
④ #topicBtn
⑤ .media-extension .plugin:nth-child(2) .d-select-placeholder
⑥ .media-settings>div>div:nth-child(2) .d-select-description
⑦ .el-radio-group label:nth-child(1) input - 立即发布
.el-radio-group label:nth-child(2) input - 定时发布
.el-radio-group .date-picker input - 时间2025-06-21 15:14
⑧ .publishBtn
#### STEP 31 上传图片
点击上传图片后(③ div.outarea.upload-c .creator-tab:nth-child(3) )
![[xhspublisher-7.png]]
**CSS选择器**
① .publish-c .media-area-new .img-upload-area .entry
② .titleInput .d-text
③ #quillEditor .ql-editor
④ #topicBtn
⑤ .media-extension .plugin:nth-child(2) .d-select-placeholder
⑥ .media-settings>div>div:nth-child(2) .d-select-description
⑦ .el-radio-group label:nth-child(1) input - 立即发布
.el-radio-group label:nth-child(2) input - 定时发布
.el-radio-group .date-picker input - 时间2025-06-21 15:14
⑧ .publishBtn
### Markdown解析
### 数据结构
#### 数据来源
- markdown header
解析markdown笔记的header部分
image : 封面图片,文字内容的封面图片
xhstitle : **新增**,小红书标题
xhsdate : **定时发布**时间,不存在或留空表示**立即发布**
xhstags : **新增**,作为小红书的#tags并加入原header中的tags内容。
xhswhere : 小红书中**你在哪里/地点**。
xhsopen : yes-公开可见no-仅自己可见
- markdown content
解析markdown内容并获取[xhs内容/]
- 数据结构
xhsdata =
{
"filename": {
"title": "Labubu爆火现象",
"date": "2025-06-19 11:00",
"tags": ["潮玩","labubu"……],
"where": "杭州市西湖风景名胜区",
"open": "yes",
"content": ["line1","line2","line3"……]
}
}
### 小红书发布流程
- 利用selenium登录首次输入phone number并记录cookie。以后尝试读取cookies自动登录无法登陆则重新输入phone number。
- 发布文章
### AI大模型
使用**豆包火山引擎**
#### 代码生成
### CONFIG
解析markdown内容时每页内容的行数和总字数限制
page-line-number-limit
page-line-word-count-limit
page-word-count-limit
---
### ideas
#### 20250901
从不同的源爬取内容<!--xhs-->,渲染成图片,发布到小红书。
- douban读书摘录、影评高赞(如top3)内容。
- 自己ibook读书标注。
输入书名/电影名,完成内容采集和发布。(<!--xhs-->打标签❓)
配置:
- 分类:书评、影评、游记
- 来源豆瓣书摘豆瓣评论ibook标注
### notes
- 游记拍照是在说明“添加说明”中增加照片描述。说明格式filename 地点 景物 description
```
for f in *.jpg; do sips -g description "$f" | awk -F: '/description/ {print f, $2}' f="$f"; done
(venv) gavin@GavinsMAC Downloads % sips -g all IMG_7015.jpg
/Users/gavin/Downloads/IMG_7015.jpg
pixelWidth: 1320
pixelHeight: 2425
typeIdentifier: public.jpeg
format: jpeg
formatOptions: default
dpiWidth: 216.000
dpiHeight: 216.000
samplesPerPixel: 3
bitsPerSample: 8
hasAlpha: no
space: RGB
profile: sRGB IEC61966-2.1
description: 航班✈️
```
todolist:
- 调用大模型进行内容、图片、视频创作。 [AI大模型](#AI大模型)
- 字体和模版随机选择,引入随机性
闪念:
- 内容框架 & 内容分页展示,文字 + 装饰图,装饰图大模型自动生成。
- markdown header 中定义模版
- **使用html作为中间的渲染过程**增强渲染的灵活性和丰富度。markdown - html - 图片
### 链接&参考
- [xhs_ai_publisher](https://github.com/yourusername/xhs_ai_publisher.git)
- [豆包大模型控制台](https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement?LLM=%7B%7D&OpenTokenDrawer=false&tab=LLM)
- [selenium with python](https://selenium-python-zh.readthedocs.io/en/latest/)
- [selenium WebDriver](https://www.selenium.dev/zh-cn/documentation/webdriver/)
- [markdown-it](https://markdown-it.docschina.org)