Csdn

From AceDataCloud/Skills · View interactive version

Csdn is an AI agent skill from the GitHub repository AceDataCloud/Skills. Read and publish on CSDN (blog.csdn.net) with the user's own login cookies (BYOC) — list their published articles with view/like/comment stats, inspect one article, and publish a new article. Use when the user mentions CSDN, "我的 CSDN 文章", reading their article stats (阅读/点赞), or publishing/发文 to CSDN

How to use this skill

Skill file

csdn — read & publish on CSDN via your own cookies

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 — urllib + hmac (the editor's

save endpoint requires an HMAC signature, computed with stdlib).

The connector injects the cookie jar as an env var:

The CLI reads it for you.

CSDN fronts its APIs with a WAF; the CLI already sends a full browser

fingerprint so reads aren't 403'd. An upstream WAF 403 can mean the cookie

expired or CSDN requires a captcha. Check the error classification below.

Image downloads honor standard HTTP_PROXY / HTTPS_PROXY and NO_PROXY.

A configured proxy must enforce public destinations when resolving hostnames;

without one, the script performs its existing local DNS checks.

CLI

The skill ships CODE0 — self-contained, stdlib only.

# $SKILL_DIR can point at another skill loaded this turn — anchor on our own
# script, and re-run this at the top of every Bash block (fresh shell each time).
CSDN="$SKILL_DIR/scripts/csdn.py"; [ -f "$CSDN" ] || CSDN=$(find /tmp -maxdepth 8 -path '*/skills/*/scripts/csdn.py' 2>/dev/null | head -1)
[ -f "$CSDN" ] || { echo "csdn script not found (SKILL_DIR=$SKILL_DIR)" >&2; exit 1; }
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 stats

Stats come straight from CSDN: view_count (阅读), digg_count (点赞),

comment_count (评论), collect_count (收藏).

Verify the connection first

CSDN="$SKILL_DIR/scripts/csdn.py"; [ -f "$CSDN" ] || CSDN=$(find /tmp -maxdepth 8 -path '*/skills/*/scripts/csdn.py' 2>/dev/null | head -1)
python3 "$CSDN" whoami
# → {"username": "...", "nickname": "...", "articles_total": 0}

On an upstream WAF 403 / auth error, the cookie may be expired or CSDN may require

a captcha — tell the user to reconnect at

<https://studio.acedata.cloud/console/connectors>. Do not retry in a loop.

For the read commands above, a connector runtime failure includes error_code: cookie_response_denied,

request_denied, response_refused, redirect_denied, lease_expired, or

upstream_unavailable. Report that code and its message; do not claim the CSDN

cookie expired or request reconnection solely because of it. For lease_expired,

start a new execution; for upstream_unavailable, retry later without a retry loop.

Publishing — GATED (dry-run unless trailing `--confirm`)

publish writes to the user's real account. Content is Markdown. Without a

trailing --confirm it dry-runs. --confirm is honored **only as the last

argument**. Always show the dry-run, get an explicit "yes", then re-run with

--confirm last.

CSDN="$SKILL_DIR/scripts/csdn.py"; [ -f "$CSDN" ] || CSDN=$(find /tmp -maxdepth 8 -path '*/skills/*/scripts/csdn.py' 2>/dev/null | head -1)
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

name. Default to --draft-only unless the user clearly asked to go live.

Images

publish automatically re-hosts external markdown images (![](url)) onto

CSDN's own CDN (i-blog.csdnimg.cn) before saving — CSDN 防盗链 blocks external

images, and saving an article full of external URLs can even time out. Images

already on csdnimg.cn are left alone; pass --no-rehost-images to skip. An

image that fails to upload keeps its original URL (never blocks the post).

Gotchas — surface before the user is surprised

never loop-retry a WAF block.

bundle; if CSDN rotates it, publish fails loudly (reads still work).

captured cookie; the user owns that risk.

Record the output

After you successfully publish and obtain the live result URL, call the built-in

publish_artifact tool ONCE so the user can track this deliverable in My Outputs:

publish_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 status="failed") if publishing failed.

See _shared/artifacts.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.