在Linux上自动发布知乎专栏文章(Chrome附加/VNC)。Agent编写标题和正文,然后执行zhihu_publish.sh脚本并传入--publish --submit参数。触发知乎发帖功能。
This skill is self-contained: everything runs from {baseDir}/scripts/. No other repository files are required.
Publish column articles (专栏) by attaching to Chrome on 127.0.0.1:9222 after the user logged in via VNC.
Uses exec + bash {baseDir}/scripts/zhihu_publish.sh — not Browser Relay (see ClawHub zhihu-post for Windows).
Run once on the Linux server:
bash
bash {baseDir}/scripts/setup.sh
bash {baseDir}/scripts/install_chromedriver.sh
bash {baseDir}/scripts/start_chrome_debug.sh
In VNC: log in to Zhihu in that Chrome window.
Verify:
bash
bash {baseDir}/scripts/zhihu_publish.sh --check --json
Expect: "ok": true, "logged_in": true.
Details: {baseDir}/references/linux-vnc-setup.md
start_chrome_debug.sh){baseDir}/scripts/#ScriptPurposesetup.sh``pip install --user selenium + chmod (no sudo)install_chromedriver.shInstall chromedriver (once)start_chrome_debug.shStart Chrome (VNC window)ensure_chrome_debug.shRestart Chrome if closed (keeps login profile)zhihu_publish.shAgent entry — always use thiszhihu_attach_standalone.pyCalled by zhihu_publish.sh
ParameterHow--title "..."Required--body-file /pathPreferred for long text — write file first, then pass path--body "..."Short text only--publishOpen editor and fill--submitClick 发布 (real post; omit for dry-run)--jsonJSON result for the agent--no-ensure-chromeSkip auto-start (only if Chrome is already running)
Auto-start: Every zhihu_publish.sh run automatically calls ensure_chrome_debug.sh first. If the user closed the browser, Chrome restarts in the background with the same profile ( ~/.chrome-zhihu-automation) — login usually persists. No need to pass a separate flag unless debugging.
Never put user content inside one shell string. Use separate exec args or --body-file.
This skill does not generate articles by itself. You (the OpenClaw agent / LLM) supply them:
FieldSourceTitleUser gives it explicitly, OR you draft a short headline from the topic (≤ 100 chars, no clickbait unless asked).BodyUser pastes it, OR you write the full article (Markdown/plain text) based on the user’s topic, then save to a file.
Typical flow when the user says 「帮我写一篇关于 XX 发知乎」:
/tmp/zhihu_post_body.txt (use your file/write tool — not inline in bash).zhihu_publish.sh with --title, --body-file, --publish, --submit, --json.Do not ask the user to run bash commands. Do not put the article body in exec args.
Default for normal user requests ( 发知乎 / 发帖 / 发布到知乎): skip --check, go straight to publish with --submit.
Chrome is auto-started by zhihu_publish.sh if port 9222 is down.
TITLE (string)./tmp/zhihu_post_body.txt (UTF-8).bash
bash {baseDir}/scripts/zhihu_publish.sh \
--publish \
--title "TITLE" \
--body-file /tmp/zhihu_post_body.txt \
--submit \
--json
"ok": true, "published": true, share url (should be zhuanlan.zhihu.com/p/... without /edit).error field; if login/session issue, tell user to log in via VNC once, then retry Step B (still no routine --check).Use no --submit only if the user says 预览 / 先填草稿 / 不要发布 / 我确认后再发.
--check only on failure#Run --check --json only when Step B returns login/API errors — not before every post.
text
command: bash
args: [
"{baseDir}/scripts/zhihu_publish.sh",
"--publish",
"--title", "今天我挺开心的",
"--body-file", "/tmp/zhihu_post_body.txt",
"--submit",
"--json"
]
Write /tmp/zhihu_post_body.txt in a separate step before this exec.
Selenium attach requires chromedriver even when Chrome is already running.
Default install: ~/.local/bin/chromedriver (no sudo). System-wide: sudo env CHROMEDRIVER_INSTALL_DIR=/usr/local/bin bash .../install_chromedriver.sh
bash
bash {baseDir}/scripts/install_chromedriver.sh
bash {baseDir}/scripts/verify_chrome_stack.sh
If you installed Chrome via dnf RPM (e.g. 148.0.7778.215), chromedriver must be the same build from Chrome for Testing — see {baseDir}/references/linux-vnc-setup.md.
SymptomActionchromedriver not in PATHinstall_chromedriver.sh (writes scripts/chromedriver.env)Permission denied installing driverRe-run install_chromedriver.sh (uses ~/.local/bin); or sudo for /usr/local/binVersion mismatchverify_chrome_stack.sh; re-download driver for your google-chrome-stable --versionCannot connect to 9222Usually auto-fixed on next zhihu_publish.sh run; or ensure_chrome_debug.shBrowser closedAuto-restart on publish; re-login in VNC only if --check returns 401Chrome starts but no window on VNCSet DISPLAY for the OpenClaw/exec user (e.g. export DISPLAY=:1)No selenium modulebash {baseDir}/scripts/setup.sh``Permission denied on pip installUse setup.sh (installs to ~/.local); do not run bare pip install as non-rootPython 3.6setup installs selenium 3.141.x automatically; attach script supports itAPI 401Re-login in VNC--submit but no publishJSON error: form_not_filled / publish_button_not_found / publish_not_confirmed; check VNC + scripts/screenshots/
--submit when the user wants a real post (normal 发知乎 / 发布 requests).--submit only for explicit preview/draft requests.