csdn
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecsdn — read & publish on CSDN via your own cookies
csdn — 通过自有Cookie在CSDN上读写内容
Drives the user's real CSDN account through the same web APIs the site's own
editor uses, authenticated by the login cookie they captured with the ACE
extension. No browser, no third-party deps — + (the editor's
save endpoint requires an HMAC signature, computed with stdlib).
urllibhmacThe connector injects the cookie jar as an env var:
- — a JSON array of cookies. Secret — never echo or print it. The CLI reads it for you.
CSDN_COOKIES
CSDN fronts its APIs with a WAF; the CLI already sends a full browser fingerprint so reads aren't 403'd. If you still get a WAF 403, the cookie expired — have the user reconnect.
通过CSDN官网编辑器使用的相同Web API,驱动用户的真实CSDN账号,认证方式为用户通过ACE扩展捕获的登录Cookie。无需浏览器,无需第三方依赖——仅使用 + (编辑器的保存接口需要HMAC签名,通过标准库计算)。
urllibhmac连接器将Cookie Jar注入为环境变量:
- — 一个Cookie的JSON数组。保密内容——切勿回显或打印。 CLI会自动读取该变量。
CSDN_COOKIES
CSDN的API由WAF防护;CLI已发送完整的浏览器指纹,因此读取操作不会返回403错误。如果仍收到WAF 403错误,说明Cookie已过期——请用户重新连接。
CLI
CLI
The skill ships — self-contained, stdlib only.
scripts/csdn.pysh
CSDN=$SKILL_DIR/scripts/csdn.py
python3 $CSDN whoami # who is logged in (+ total article count)
python3 $CSDN articles --limit 20 # my published articles + stats
python3 $CSDN article <article-id> # one article's statsStats come straight from CSDN: (阅读), (点赞),
(评论), (收藏).
view_countdigg_countcomment_countcollect_count本技能附带了——独立脚本,仅依赖标准库。
scripts/csdn.pysh
CSDN=$SKILL_DIR/scripts/csdn.py
python3 $CSDN whoami # 查看当前登录用户(+ 文章总数)
python3 $CSDN articles --limit 20 # 查看我的已发布文章及统计数据
python3 $CSDN article <article-id> # 查看单篇文章的统计数据统计数据直接来自CSDN:(阅读)、(点赞)、(评论)、(收藏)。
view_countdigg_countcomment_countcollect_countVerify the connection first
先验证连接
sh
python3 $CSDN whoamish
python3 $CSDN whoami→ {"username": "...", "nickname": "...", "articles_total": 1597}
→ {"username": "...", "nickname": "...", "articles_total": 1597}
On a WAF 403 / auth error the cookie is expired — tell the user to reconnect at
<https://auth.acedata.cloud/user/connections>. Do **not** retry in a loop.
如果出现WAF 403/认证错误,说明Cookie已过期——告知用户前往<https://auth.acedata.cloud/user/connections>重新连接。**切勿循环重试。**Publishing — GATED (dry-run unless trailing --confirm
)
--confirm发布功能——受保护(除非末尾添加--confirm
,否则仅为试运行)
--confirmpublish--confirm--confirm--confirmsh
python3 $CSDN publish --title "标题" --content-file a.md # dry-run
python3 $CSDN publish --title "标题" --content-file a.md --draft-only --confirm # private draft (status=2)
python3 $CSDN publish --title "标题" --content-file a.md --tags "AI,Python" --confirm # PUBLIC, goes live- saves a private draft (CSDN
--draft-only) — safe, nothing public.status=2 - Without the article is published publicly under the user's name. Default to
--draft-onlyunless the user clearly asked to go live.--draft-only - is a comma-separated list of article tags.
--tags
publish--confirm--confirm--confirmsh
python3 $CSDN publish --title "标题" --content-file a.md # 试运行
python3 $CSDN publish --title "标题" --content-file a.md --draft-only --confirm # 保存为私有草稿(status=2)
python3 $CSDN publish --title "标题" --content-file a.md --tags "AI,Python" --confirm # 公开发布,立即上线- :保存为私有草稿(CSDN的
--draft-only)——安全,不会公开。status=2 - 若未添加,文章将以用户名义公开发布。除非用户明确要求上线,否则默认使用
--draft-only。--draft-only - :文章标签的逗号分隔列表。
--tags
Images
图片处理
publishi-blog.csdnimg.cncsdnimg.cn--no-rehost-imagespublishi-blog.csdnimg.cncsdnimg.cn--no-rehost-imagesGotchas — surface before the user is surprised
注意事项——提前告知用户避免意外
- This is the user's real CSDN account. Confirm before any publish.
- Cookie expiry / WAF 403: reconnect at auth.acedata.cloud/user/connections — never loop-retry a WAF block.
- The editor save endpoint is signed with an HMAC key baked into CSDN's web bundle; if CSDN rotates it, publish fails loudly (reads still work).
- Never print — it is full account access.
CSDN_COOKIES - ToS: cookie automation acts only on the user's own account with their own captured cookie; the user owns that risk.
- 这是用户的真实CSDN账号。发布前务必确认。
- Cookie过期/WAF 403错误:前往auth.acedata.cloud/user/connections重新连接——切勿循环重试WAF拦截请求。
- 编辑器的保存接口使用CSDN网页包中内置的HMAC密钥签名;如果CSDN轮换了该密钥,发布功能会直接失败(但读取功能仍可正常使用)。
- 切勿打印——该变量包含完整的账号访问权限。
CSDN_COOKIES - 服务条款(ToS):Cookie自动化仅在用户自己的账号上操作,且使用用户自行捕获的Cookie;相关风险由用户自行承担。
Record the output
记录输出
After you successfully publish and obtain the live result URL, call the built-in
tool ONCE so the user can track this deliverable in My Outputs:
publish_artifactpublish_artifact(kind="article", channel="csdn", title="<title>", url="<the REAL returned URL>", status="delivered")Use the real returned URL — never fabricate one. Call it once per published item,
only after delivery is confirmed; skip it (or use ) if publishing failed.
See .
status="failed"_shared/artifacts.md成功发布并获取到文章的实际访问URL后,调用内置的工具一次,以便用户在我的输出中跟踪该交付成果:
publish_artifactpublish_artifact(kind="article", channel="csdn", title="<title>", url="<the REAL returned URL>", status="delivered")使用实际返回的URL——切勿伪造。仅在确认交付成功后为每个已发布项目调用一次;如果发布失败,请跳过调用(或使用)。详情请查看。
status="failed"_shared/artifacts.md