juejin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

juejin — read & publish on 掘金 via your own cookies

juejin — 使用自有Cookie在掘金上读写内容

Drives the user's real 掘金 account through the same
api.juejin.cn
web endpoints the site 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:
  • JUEJIN_COOKIES
    — a JSON array of cookies. Secret — never echo or print it.
通过掘金官网使用的
api.juejin.cn
接口调用用户的真实掘金账号,使用用户通过ACE扩展捕获的登录Cookie进行身份验证。无需浏览器,无第三方依赖——仅使用
urllib
连接器会将Cookie Jar作为环境变量注入:
  • JUEJIN_COOKIES
    — Cookie的JSON数组。机密内容——切勿回显或打印。

CLI

CLI

The skill ships
scripts/juejin.py
— self-contained, stdlib only.
sh
JJ=$SKILL_DIR/scripts/juejin.py
python3 $JJ whoami                       # who is logged in (+ totals)
python3 $JJ articles --limit 20          # my published articles + stats
python3 $JJ article <article-id>         # one article's stats
Stats come straight from 掘金:
view_count
(阅读),
digg_count
(点赞),
comment_count
(评论),
collect_count
(收藏).
audit_status
2 = online.
该工具附带了
scripts/juejin.py
——独立脚本,仅依赖标准库。
sh
JJ=$SKILL_DIR/scripts/juejin.py
python3 $JJ whoami                       # 查询当前登录用户信息(含统计数据)
python3 $JJ articles --limit 20          # 查看已发布文章及数据统计
python3 $JJ article <article-id>         # 查看单篇文章的详细数据
数据直接来自掘金:
view_count
(阅读量)、
digg_count
(点赞数)、
comment_count
(评论数)、
collect_count
(收藏数)。
audit_status
为2表示已上线。

Verify the connection first

先验证连接有效性

sh
python3 $JJ whoami
sh
python3 $JJ whoami

→ {"user_id": "...", "name": "...", "post_article_count": 336}

→ {"user_id": "...", "name": "...", "post_article_count": 336}


On an auth error (`err_no` 401 / "请登录") the cookie is expired — have the user
reconnect at <https://auth.acedata.cloud/user/connections>. Do **not** loop-retry.

若出现认证错误(`err_no`为401 / “请登录”),说明Cookie已过期——请用户前往<https://auth.acedata.cloud/user/connections>重新连接。**请勿循环重试。**

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

发布功能——受保护(除非末尾添加
--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.
sh
python3 $JJ publish --title "标题" --content-file a.md                       # dry-run
python3 $JJ publish --title "标题" --content-file a.md --draft-only --confirm   # private draft
python3 $JJ publish --title "标题" --content-file a.md \
    --category-id 6809637769959178254 --tag-ids 6809640407484334093 --confirm # PUBLIC
  • --draft-only
    creates a private draft (掘金
    article_draft
    ) — safe.
  • To actually publish (go through 审核), 掘金 requires a valid
    --category-id
    and at least one
    --tag-id
    . Without them, use
    --draft-only
    and let the user pick category/tags in the 掘金 editor. Default to
    --draft-only
    .
publish
命令会写入用户的真实账号。内容格式为Markdown。若未在末尾添加
--confirm
,则仅为试运行。
--confirm
仅在作为最后一个参数时生效。需先展示试运行结果,获取用户明确的“确认”后,再重新运行命令。
sh
python3 $JJ publish --title "标题" --content-file a.md                       # 试运行
python3 $JJ publish --title "标题" --content-file a.md --draft-only --confirm   # 发布为私有草稿
python3 $JJ publish --title "标题" --content-file a.md \
    --category-id 6809637769959178254 --tag-ids 6809640407484334093 --confirm # 公开发布
  • --draft-only
    会创建私有草稿(掘金的
    article_draft
    )——安全无风险。
  • 正式发布(进入审核流程),掘金要求提供有效的
    --category-id
    和至少一个
    --tag-id
    。若未提供这些参数,请使用
    --draft-only
    ,让用户在掘金编辑器中选择分类和标签。默认使用
    --draft-only

Gotchas

注意事项

  • This is the user's real 掘金 account. Confirm before any publish.
  • Publishing without a category + tag is rejected in 审核; prefer
    --draft-only
    .
  • Never print
    JUEJIN_COOKIES
    — it is full account access.
  • ToS: acts only on the user's own account with their own captured cookie.
  • 操作的是用户的真实掘金账号。发布前务必确认。
  • 未指定分类和标签的发布请求会被审核驳回;优先使用
    --draft-only
  • 切勿打印
    JUEJIN_COOKIES
    ——它拥有账号的完整访问权限。
  • 服务条款:仅在用户自有账号上执行操作,且使用用户自行捕获的Cookie。

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="juejin", 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
.
成功发布并获取文章的在线链接后,调用内置的
publish_artifact
工具一次,以便用户在“我的输出”中跟踪该成果:
publish_artifact(kind="article", channel="juejin", title="<title>", url="<the REAL returned URL>", status="delivered")
请使用真实返回的链接——切勿伪造。每发布一篇文章调用一次,仅在确认发布成功后调用;若发布失败,请跳过(或使用
status="failed"
)。详情请查看
_shared/artifacts.md