zhihu
GitHub通过用户自有Cookie读写知乎,支持查看登录状态、文章列表及点赞评论统计,并安全发布或保存草稿。
Trigger Scenarios
Install
npx skills add NeverSight/learn-skills.dev --skill zhihu -g -y
SKILL.md
Frontmatter
{
"name": "zhihu",
"license": "Apache-2.0",
"metadata": {
"author": "acedatacloud",
"version": "1.1"
},
"connections": [
"zhihu"
],
"description": "Read and publish on Zhihu (知乎) with the user's own login cookies (BYOC) — list their published articles with vote\/comment stats, inspect one article, and publish a new article. Use when the user mentions 知乎 \/ Zhihu, \"我的知乎文章\", reading their article stats (点赞\/评论), or publishing\/发文 to Zhihu.",
"when_to_use": "Trigger for anything on the user's Zhihu (知乎) account driven by their own\nlogin cookie: show who they are, list their published articles with\nvote-up \/ comment counts, look at one article's stats, or publish a new\narticle. This acts as the user's real account, so writes are gated behind\nan explicit confirmation.\n",
"allowed_tools": [
"Bash"
]
}
zhihu — read & publish on Zhihu via your own cookies
Drives the user's real Zhihu 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 — just urllib.
The connector injects the cookie jar as an env var:
ZHIHU_COOKIES— a JSON array of{name, value, domain, path, ...}cookies. Secret — never echo or print it. The CLI reads it for you.
CLI
The skill ships scripts/blog.py — self-contained, stdlib only.
BLOG=$SKILL_DIR/scripts/blog.py
# Read (run directly)
python3 $BLOG whoami # who is logged in
python3 $BLOG articles --limit 20 # my published articles + stats
python3 $BLOG article <article-id> # one article's details + stats
Verify the connection first
python3 $BLOG whoami
# → {"id": "...", "name": "崔庆才丨静觅", "url_token": "cui-qing-cai", ...}
On a 401/403 the cookie is expired — tell the user to reconnect at
https://auth.acedata.cloud/user/connections (re-capture with the ACE
extension). Do not retry in a loop.
Reading recipes
| Goal | Command |
|---|---|
| Who am I | python3 $BLOG whoami |
| My latest articles + vote/comment counts | python3 $BLOG articles --limit 20 |
| Next page | python3 $BLOG articles --limit 20 --offset 20 |
| One article's stats | python3 $BLOG article <id> |
Stats come straight from Zhihu: voteup_count (赞同), comment_count (评论).
Zhihu does not expose per-article read counts on these endpoints.
Publishing — GATED (dry-run unless trailing --confirm)
publish writes to the user's real account. Without a trailing --confirm it
dry-runs (prints what it would do, changes nothing). --confirm is honored
only as the last argument, so a title/content containing "--confirm" can
never silently go live. Always show the dry-run to the user, get an explicit
"yes", then re-run with --confirm last.
# Content is HTML. For Markdown, convert to HTML first (e.g. `pandoc -f gfm -t html`).
python3 $BLOG publish --title "标题" --content-file article.html # dry-run
python3 $BLOG publish --title "标题" --content-file article.html --draft-only --confirm # save a private draft
python3 $BLOG publish --title "标题" --content-file article.html --confirm # PUBLIC, goes live
--draft-onlystops after saving a private draft (safe — nothing public).- Without
--draft-only, the article is published publicly under the user's name. Default to--draft-onlyunless the user clearly asked to go live. - Images are auto-hosted. Zhihu strips any
<img>whosesrcis not on its own CDN, so on--confirmthe CLI re-uploads every external image (HTML<img src>and Markdown, plusdata:URIs) to Zhihu's image service and rewrites the URLs first — images already on*.zhimg.comare left untouched. The result reportsimages: {found, rehosted, failed}; the dry-run reportsimages_found. Pass--no-imagesto skip this. So you can hand the CLI HTML/Markdown with normal public image URLs and the pictures survive.
Gotchas — surface before the user is surprised
- This is the user's real Zhihu account. Confirm before any publish; reading exposes their own private drafts.
- Cookie expiry: Zhihu cookies are short-lived. A
401/403means reconnect at auth.acedata.cloud/user/connections — never loop-retry. - ToS: cookie automation is against most platforms' terms. This only ever acts on the user's own account with their own captured cookie; the user owns that risk. Never use it to scrape other people's content at scale.
- Never print
ZHIHU_COOKIES— it is full account access. - Scope: Zhihu only. Other Chinese platforms (掘金 / CSDN / …) ship as their
own per-platform skills (e.g.
csdn,juejin), each with its own connector — not a--platformswitch here.
Version History
- e0220ca Current 2026-07-05 22:56


