Csdn Upload logo

Csdn Upload

Community
ricky-theseus
csdn-upload

通过 Playwright + 直连 API(X-Ca HMAC-SHA256 签名)将本地博文批量上传到 CSDN 草稿箱。三态管理:未上传 → 草稿箱 → 已发布。

Overview

Publisherricky-theseus
RepositoryDaisyWriter
Skill namecsdn-upload
Stars
77
Forks
5
Bundled files
1
LicenseGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ricky-theseus on GitHub. Read the source before you install it.

Installation

Install the Csdn Upload AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ricky-theseus/DaisyWriter/tree/master/skills/tech/csdn-upload
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ricky-theseus/DaisyWriter.git /tmp/DaisyWriter
mkdir -p .claude/skills
cp -r /tmp/DaisyWriter/skills/tech/csdn-upload .claude/skills/csdn-upload
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Csdn Upload in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Csdn Upload on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Csdn Upload is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

CSDN 草稿批量上传

三态管理

状态含义判定依据
未上传本地有草稿,未上传到 CSDN不在 csdn_article_map.json,不在已发表集合
草稿箱已上传到 CSDN 但未发布csdn_article_map.json 中 status: "draft"
已发布已在 CSDN 公开发布published.json 中有记录,或在 已发表/ 目录

数据流向:

未上传 ──upload──→ 草稿箱 ──manual publish──→ 已发布
                       │
                       └──sync──→ csdn_article_map.json (status→published)

使用

首次登录

bash
python scripts/playwright_uploader.py --login

弹出浏览器 → 手动登录 CSDN → 在编辑器页面出现后关闭浏览器 → 登录态保存到 chrome_profile/。

查看状态

bash
python scripts/playwright_uploader.py --dry-run

列出所有草稿的三态分布,不下发任何请求。

上传到草稿箱

bash
python scripts/playwright_uploader.py
python scripts/playwright_uploader.py --no-confirm   # 跳过确认
python scripts/playwright_uploader.py --retry-failed  # 只重试上次失败的

使用直连 API(非 UI 操作),自动重试频率限制。

同步已发布状态

bash
python scripts/playwright_uploader.py --sync

对比 published.json / 已发表/ 目录,将 csdn_article_map.json 中对应文章从 draft 标记为 published。

命令参考

命令作用
--login首次登录,保存浏览器状态
--dry-run预览三态分布,不操作
--sync同步已发表状态到映射文件
--retry-failed只重试上次失败的未上传文章
--no-confirm跳过确认提示直接上传

工作原理

架构

Python 脚本 ──Playwright──→ 浏览器(提供 Cookie 环境)
                │
                ├── page.evaluate(JS) 注入 HMAC 签名计算
                └── fetch() → POST bizapi.csdn.net/saveArticle

不使用 UI 操作(CSDN 的 Vue 3 contenteditable 编辑器不稳定且不触发 saveArticle API)。

X-Ca 签名算法

CSDN 的 bizapi 使用阿里云 API 网关风格的四层签名:

参数值
X-Ca-Key203803574
X-Ca-Secret9znpamsyl2c7cdrr9sas0le9vbc3r6ba
X-Ca-Nonce每次请求新生成的 UUID v4
X-Ca-Signature-Headersx-ca-key,x-ca-nonce

签名字符串格式(HMAC-SHA256 → Base64):

POST\n
*/*\n
\n
application/json\n
\n
x-ca-key:{key}\n
x-ca-nonce:{nonce}\n
/path

签名在浏览器内用 crypto.subtle.sign('HMAC', ...) 计算,避免 Python 端逆向兼容问题。

频率限制

  • 每次 POST 后至少等待 10 秒
  • 触发频率限制后重试,退避策略:10s → 20s → 失败(最多 3 次)
  • 连续多发容易触发 CSDN 的"请求太过频繁"防护

输入源

  • 递归搜索 博文/**/草稿/*.md
  • 每篇博文要求(技术博文规范):
    • 最低 800 中文字符(不含代码块/Mermaid)
    • 含 Mermaid 图
    • 标题、分类、标签等元信息上传时由脚本构造

状态存储

三态不依赖数据库,由两个 JSON 文件协同完成:

csdn_article_map.json — 上传台账(本 skill 维护)

字段类型说明
versionint结构版本号,当前 1
articlesobjectkey = 相对路径(博文/.../草稿/xxx.md),value = 文章记录
updated_atstringISO 时间戳,最近一次写入时间

每篇文章记录:

json
{
  "id": 162305841,
  "url": "https://blog.csdn.net/.../162305841",
  "title": "文章标题",
  "uploaded_at": "2026-06-25T14:24:40.180430",
  "status": "draft",
  "published_at": null
}
字段类型说明
idintCSDN 分配的 article id
urlstringCSDN 文章链接
titlestring上传时的标题
uploaded_atstringISO 时间戳,上传时间
statusenum"draft" | "published"
published_atstring?标记为已发布的时间(--sync 写入)

谁写:upload_articles() 在成功 POST 后写入,sync_published() 在 --sync 时更新 status。

谁读:classify() 读取来判断"草稿箱",sync_published() 读取来比对已发表。

生命周期:首次上传时创建,随每次上传/同步自动更新。不移除记录(保留审计线索)。

published.json — 已发表台账(外部系统维护,本 skill 只读)

路径:D:/Writer/.author/published.json

由项目级发布流程维护,本 skill 只读不写。结构示例:

字段类型说明
worksarray长篇作品(小说等)的已发表章节
tech_articlesarray技术博文已发表记录
agent_articlesarrayAI Agent 专题已发表记录

每篇记录包含 title 字段,本 skill 提取 title 的 lowercase 值做字符串匹配,判断文章是否已发布。

谁写:外部发布流程(非本 skill)。

谁读:get_published_titles() 读取,供 classify() 判断"已发布"。

状态判定逻辑

classify(draft):
    1. title.lower() in published.json.titles  → "已发布"
    2. rel_path in csdn_article_map.json       → "草稿箱"
    3. 否则                                      → "未上传"

sync_published() 额外步骤:扫描 博文/**/已发表/*.md 文件头提取 title,与 published.json 互补覆盖。

.upload_failed.json — 失败重试缓存(临时)

只在 --retry-failed 场景使用。每次上传批次结束后,将失败文章的相对路径写入此文件,供下次 --retry-failed 读取。

字段类型说明
failedarray[string]失败文章的相对路径列表
updated_atstringISO 时间戳

不长期保留,成功重试后自然不再使用。

文件

csdn-upload/
├── SKILL.md                            # 本文件
├── scripts/
│   └── playwright_uploader.py          # 唯一脚本:登录 + 上传 + 同步
├── chrome_profile/                      # Chromium 持久化用户数据(登录态)
├── csdn_article_map.json               # 上传台账(自动生成,追踪三态)
└── .upload_failed.json                 # 失败重试缓存(自动生成,--retry-failed 使用)

注意事项

  • 登录过期:CSDN 登录态数天后失效,重新 --login
  • 只存草稿不发布:pubStatus: "draft",不会触发发布
  • 图片暂不支持:不会自动上传博文中的图片
  • API key/secret:硬编码在脚本中。如果 CSDN 更换密钥需要重新分析 app 入口 chunk

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Csdn Upload AI skill do?

通过 Playwright + 直连 API(X-Ca HMAC-SHA256 签名)将本地博文批量上传到 CSDN 草稿箱。三态管理:未上传 → 草稿箱 → 已发布。

Why use Csdn Upload on TypingMind?

Because you install it once and use it with any model. Csdn Upload is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Csdn Upload in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ricky-theseus/DaisyWriter/tree/master/skills/tech/csdn-upload. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Csdn Upload?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Csdn Upload?

As many as you like. As long as a model supports skills, you can use Csdn Upload with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Csdn Upload AI skill free?

Yes. It is published on GitHub by ricky-theseus under the GPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇