zhihu-cli

知乎 CLI (pyzhihu-cli):搜索、热榜、问题/回答、发想法/提问/文章、删自己的内容、点赞关注、通知。Agent 代执行 zhihu 命令,Cookie 仅存本地。

3,891 stars

Best use case

zhihu-cli is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

知乎 CLI (pyzhihu-cli):搜索、热榜、问题/回答、发想法/提问/文章、删自己的内容、点赞关注、通知。Agent 代执行 zhihu 命令,Cookie 仅存本地。

Teams using zhihu-cli should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/pyzhihu-cli/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/baiguangmei/pyzhihu-cli/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/pyzhihu-cli/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How zhihu-cli Compares

Feature / Agentzhihu-cliStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

知乎 CLI (pyzhihu-cli):搜索、热榜、问题/回答、发想法/提问/文章、删自己的内容、点赞关注、通知。Agent 代执行 zhihu 命令,Cookie 仅存本地。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# zhihu-cli 技能

## 前提

- **已安装**:`zhihu` 在 PATH 中(`uv tool install pyzhihu-cli` / `pipx install pyzhihu-cli` / `pip install pyzhihu-cli`)。
- **路径**:配置与二维码路径 — **Linux/macOS**:`~/.zhihu-cli/`(如 `~/.zhihu-cli/cookies.json`、`~/.zhihu-cli/login_qrcode.png`);**Windows**:`%USERPROFILE%\.zhihu-cli\`(如 `%USERPROFILE%\.zhihu-cli\cookies.json`、`%USERPROFILE%\.zhihu-cli\login_qrcode.png`)。
- **配置**:登录态存于上述 `cookies.json`;**不得将 Cookie 上传或写入对话/日志**。
- **登录方式**:仅两种 — **扫码** `zhihu login --qrcode`、**粘贴 Cookie** `zhihu login --cookie "z_c0=...; _xsrf=...; d_c0=..."`。
- **扫码时**:二维码会生成到上述路径的 `login_qrcode.png`。若用 OpenClaw 发给用户,须先**复制到 OpenClaw 工作目录的 media 文件夹**再 `openclaw message send --media <media 路径>`。

---

## Instruction Scope

本技能仅限:在用户本机调用已安装的 `zhihu` 命令,执行搜索、热榜、问题/回答、发想法/提问/文章、删除自己的内容、点赞关注、收藏与通知等操作;在用户请求扫码登录且已配置 OpenClaw 时,可将二维码图片经 OpenClaw 发送至用户指定渠道。不包含:代用户将 Cookie 上传至任何第三方、访问非知乎域名、或超出上述命令范围的操作。

---

## Credentials

- **知乎登录态**:仅存于用户本机(Linux/macOS:`~/.zhihu-cli/cookies.json`;Windows:`%USERPROFILE%\.zhihu-cli\cookies.json`,权限 0600)。Agent 仅通过执行 `zhihu` 命令间接使用,**不得将 Cookie 内容上传、转发或写入对话/日志**。
- **OpenClaw**:若使用 `openclaw message send` 发送二维码,需用户自行配置 OpenClaw 及渠道凭证;本技能不声明、不持有该部分凭证。

---

## 安装与更新

- **安装**(任选其一):
  - `uv tool install pyzhihu-cli`
  - `pipx install pyzhihu-cli`
  - `pip install pyzhihu-cli`
- **更新**:按安装方式执行 `uv tool upgrade pyzhihu-cli`、`pipx upgrade pyzhihu-cli` 或 `pip install -U pyzhihu-cli`。用户问「升级/更新 zhihu」时提示其执行对应命令;不确定安装方式时可三种都给出。
- **版本**:`zhihu --version` 查看当前版本。

---

## Agent 规则

1. **诉求 → 命令**:按下表映射。
2. **数据查询必须用 --json**:凡执行**数据查询类**指令(如 `search`、`hot`、`question`、`answers`、`answer`、`user`、`user-answers`、`user-articles`、`feed`、`topic`、`collections`、`notifications`、`whoami` 等),**必须**带 `--json`,以获取 API 返回的完整数据,便于解析、汇总或向用户展示;不得仅依赖终端表格等非结构化输出。
3. **需登录时**:先 `zhihu status`;未登录则 `zhihu login --qrcode` 或引导用户 `zhihu login --cookie "..."`。
4. **扫码登录**:执行 `zhihu login --qrcode` 后,若本轮未发过二维码且用户已配置 OpenClaw → 先将二维码复制到 OpenClaw 工作目录的 `media` 文件夹,再 `openclaw message send --channel <渠道> --target <目标> --media <media 路径>/login_qrcode.png --message "请用知乎 App 扫码并确认登录"`;**保持登录进程不中断**直到成功/失败/超时;用户说「重新登录/换号」则中断当前进程再重新执行登录。**复制步骤**:Linux/macOS:`mkdir -p ~/.openclaw/workspace/media && cp ~/.zhihu-cli/login_qrcode.png ~/.openclaw/workspace/media/`;Windows:`mkdir "%USERPROFILE%\.openclaw\workspace\media" 2>nul & copy "%USERPROFILE%\.zhihu-cli\login_qrcode.png" "%USERPROFILE%\.openclaw\workspace\media\login_qrcode.png"`(若 OpenClaw 工作目录不同则替换为实际路径)。
5. **安全**:Cookie 仅本地;优先扫码,避免在不可信处粘贴 Cookie;可提醒 `zhihu logout` 清空。
6. **升级**:`uv tool upgrade pyzhihu-cli` / `pipx upgrade pyzhihu-cli` / `pip install -U pyzhihu-cli`。

---

## 诉求 → 命令 速查

| 诉求 | 命令 |
|------|------|
| 登录 / 扫码登录 | `zhihu login --qrcode` |
| Cookie 登录 | `zhihu login --cookie "z_c0=...; _xsrf=...; d_c0=..."` |
| 重新登录 / 换号 | 中断当前进程 → `zhihu login --qrcode` |
| 检查登录 | `zhihu status`;看资料 `zhihu whoami [--json]` |
| 搜索 | `zhihu search "关键词" [--type general/topic/people] [--limit N] [--json]` |
| 热榜 | `zhihu hot [--limit N] [--json]` |
| 问题 | `zhihu question <id>`;回答列表 `zhihu answers <id> [--limit N]` |
| 回答详情 | `zhihu answer <id> [--json]` |
| 用户 | `zhihu user <url_token>`;`user-answers` / `user-articles` / `followers` / `following` |
| 推荐 / 话题 | `zhihu feed`;`zhihu topic <id>` |
| 赞同 | `zhihu vote <answer_id>`;取消 `zhihu vote --neutral <id>` |
| 关注问题 | `zhihu follow-question <id>`;取消 `--unfollow` |
| 发提问 | `zhihu ask "标题" [-d "描述"] [-t 话题id ...] [-i 图 ...]` |
| 发想法 | `zhihu pin "标题" [-c "正文"] [-i 图 ...]` |
| 发文章 | `zhihu article "标题" "正文" [-t 话题id ...] [-i 图 ...]` |
| 删提问/想法/文章 | `zhihu delete-question <id>` / `delete-pin <id>` / `delete-article <id>` [-y] |
| 收藏 / 通知 | `zhihu collections`;`zhihu notifications [-l N] [--offset M]` |
| 退出 | `zhihu logout` |
| 版本 / 升级 | `zhihu --version`;升级见上规则 6 |

---

## 执行流程

```
用户诉求
  → 若「重新登录/换号」:中断当前 → zhihu login --qrcode → [发二维码] → 等完成
  → 否则:查上表得命令
    → 若该命令需登录:zhihu status → 未登录则 zhihu login --qrcode 或 --cookie
      → 若扫码且未发过图:复制到 media → openclaw message send --media ... → 保持进程
    → 执行 zhihu <子命令>(数据查询类必须带 --json)
    → 整理结果或报错提示
```

---

## 登录方式

| 方式 | 命令 |
|------|------|
| 扫码 | `zhihu login --qrcode`:终端显示二维码并保存到本地(Linux/macOS:`~/.zhihu-cli/login_qrcode.png`;Windows:`%USERPROFILE%\.zhihu-cli\login_qrcode.png`);可经 OpenClaw 发图给用户。 |
| 手动 Cookie | `zhihu login --cookie "z_c0=...; _xsrf=...; d_c0=..."`(浏览器 F12 → Network → 请求头 Cookie 复制)。 |

---

## 常用示例

```bash
zhihu login --qrcode
zhihu status
zhihu search "Python" --json
zhihu hot --limit 10
zhihu question 12345678
zhihu user someone
zhihu vote 87654321
zhihu pin "标题" -c "<p>正文</p>"
zhihu delete-pin 98765432 -y
zhihu notifications -l 10
zhihu logout
```

正文支持 HTML 富文本(`ask` 的 `-d`、`pin` 的 `-c`、`article` 的正文)。

---

## OpenClaw 发二维码(仅扫码时)

1. 确保二维码已生成(Linux/macOS:`~/.zhihu-cli/login_qrcode.png`;Windows:`%USERPROFILE%\.zhihu-cli\login_qrcode.png`)。
2. 复制到 OpenClaw 工作目录的 `media` 文件夹:
   - **Linux/macOS**:`mkdir -p ~/.openclaw/workspace/media && cp ~/.zhihu-cli/login_qrcode.png ~/.openclaw/workspace/media/`
   - **Windows(cmd)**:`mkdir "%USERPROFILE%\.openclaw\workspace\media" 2>nul & copy "%USERPROFILE%\.zhihu-cli\login_qrcode.png" "%USERPROFILE%\.openclaw\workspace\media\login_qrcode.png"`
   - **Windows(PowerShell)**:`New-Item -ItemType Directory -Force "$env:USERPROFILE\.openclaw\workspace\media" | Out-Null; Copy-Item "$env:USERPROFILE\.zhihu-cli\login_qrcode.png" "$env:USERPROFILE\.openclaw\workspace\media\login_qrcode.png"`
   (若 OpenClaw 工作目录不是默认的 `~/.openclaw/workspace` 或 `%USERPROFILE%\.openclaw\workspace`,则替换为实际路径。)
3. 发送:`openclaw message send --channel <渠道> --target <目标> --media <工作目录>/media/login_qrcode.png --message "请用知乎 App 扫码并确认登录"`(Linux/macOS 用 `~/.openclaw/workspace/media/login_qrcode.png`,Windows 用 `%USERPROFILE%\.openclaw\workspace\media\login_qrcode.png` 或 PowerShell 中 `$env:USERPROFILE\.openclaw\workspace\media\login_qrcode.png`)。
4. 不中断 `zhihu login --qrcode` 进程,等待用户完成。

---

## 错误处理

- **未登录 / 401 / 403**:先登录(`zhihu login --qrcode` 或 `--cookie`),再执行原命令。
- **超时 / 网络**:提示重试或检查网络。
- **其他**:根据 CLI 报错给简短原因与建议(如检查 ID、url_token)。

Related Skills

---

3891
from openclaw/skills

name: article-factory-wechat

Content & Documentation

humanizer

3891
from openclaw/skills

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases.

Content & Documentation

find-skills

3891
from openclaw/skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

General Utilities

tavily-search

3891
from openclaw/skills

Use Tavily API for real-time web search and content extraction. Use when: user needs real-time web search results, research, or current information from the web. Requires Tavily API key.

Data & Research

baidu-search

3891
from openclaw/skills

Search the web using Baidu AI Search Engine (BDSE). Use for live information, documentation, or research topics.

Data & Research

agent-autonomy-kit

3891
from openclaw/skills

Stop waiting for prompts. Keep working.

Workflow & Productivity

Meeting Prep

3891
from openclaw/skills

Never walk into a meeting unprepared again. Your agent researches all attendees before calendar events—pulling LinkedIn profiles, recent company news, mutual connections, and conversation starters. Generates a briefing doc with talking points, icebreakers, and context so you show up informed and confident. Triggered automatically before meetings or on-demand. Configure research depth, advance timing, and output format. Walking into meetings blind is amateur hour—missed connections, generic small talk, zero leverage. Use when setting up meeting intelligence, researching specific attendees, generating pre-meeting briefs, or automating your prep workflow.

Workflow & Productivity

self-improvement

3891
from openclaw/skills

Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude ('No, that's wrong...', 'Actually...'), (3) User requests a capability that doesn't exist, (4) An external API or tool fails, (5) Claude realizes its knowledge is outdated or incorrect, (6) A better approach is discovered for a recurring task. Also review learnings before major tasks.

Agent Intelligence & Learning

botlearn-healthcheck

3891
from openclaw/skills

botlearn-healthcheck — BotLearn autonomous health inspector for OpenClaw instances across 5 domains (hardware, config, security, skills, autonomy); triggers on system check, health report, diagnostics, or scheduled heartbeat inspection.

DevOps & Infrastructure

linkedin-cli

3891
from openclaw/skills

A bird-like LinkedIn CLI for searching profiles, checking messages, and summarizing your feed using session cookies.

Content & Documentation

notebooklm

3891
from openclaw/skills

Google NotebookLM 非官方 Python API 的 OpenClaw Skill。支持内容生成(播客、视频、幻灯片、测验、思维导图等)、文档管理和研究自动化。当用户需要使用 NotebookLM 生成音频概述、视频、学习材料或管理知识库时触发。

Data & Research

小红书长图文发布 Skill

3891
from openclaw/skills

## 概述

Content & Documentation