Skip to main content

🧢 zhihu-cli

The terminal is your new Zhihu HQ.

A feature-complete, automation-ready Zhihu CLI & Developer Toolkit.

browse · download · search · publish · analyze — all from the command line.

Python 3.12+ License: MIT GitHub Repo stars


zhihu-cli turns your terminal into a full-featured Zhihu client. Authenticate once, then browse, search, download, publish, and analyze — without ever opening a browser.

⚠️ This is an unofficial CLI for Zhihu. Use at your own risk. Not affiliated with Zhihu Inc.

👉 Looking for the DSH plugin? → dsh-plugin/


🚀 Quick Start

Requirement: Python 3.12 or newer. Check your version with python --version before installing.

# Install
pip install zhihu-toolkit

1. Authenticate

zhihu auth paste          # paste a cURL from browser DevTools
zhihu auth login          # scan a QR code with the Zhihu App
zhihu auth import         # import the session from a local browser (needs: pip install 'zhihu-toolkit[browser]')

2. Verify

zhihu auth status         # check login status and active profile

✨ What You Can Do

📖 Read & Browse

Browse Zhihu's feeds, hot lists, questions, articles, pins, and comments — all rendered in your terminal with a Rich-powered pager. Explore the real-time trending list with excerpts, scroll through your personalized recommend feed, or dive into a question and its full answer thread without clicking a single link.

💾 Download for Offline

Save any Zhihu content (articles, answers, questions, pins, videos) as clean Markdown with YAML frontmatter. Download individual pieces or batch-process from a manifest. Everything lands in ~/.zhihu-cli/downloads/, organized by type, ready for your note-taking system or offline reading.

Search questions, articles, users, and topics across Zhihu. Fine-tune result depth and quantity — all from the command line.

✍️ Publish & Edit

Write answers and articles in Markdown, publish them to Zhihu with one command. Need to update? Modify existing answers and articles from your local files. Markdown-to-HTML conversion happens automatically via Zhihu's own rendering pipeline.

💬 Interact

Vote, thank, follow, block, and comment — full social interaction without the browser. Manage collections: create, populate, and organize them. Send and receive direct messages, and stream real-time notifications and chat via MQTT.

🕸️ Scrape & Export

Batch-export your creations, activity history, answers, and articles as structured JSON. Use the universal converter to merge and normalize across formats for your own data pipeline.

📊 Analyze

Creator analytics — pull your Zhihu income data and visualize it: monthly summaries, trend charts (with EMA), advanced indicators (Bollinger Bands, MACD), derivative analysis (velocity/acceleration/jerk), weekday breakdowns, and per-content daily metrics. Charts are saved as PNGs.

NLP tools — run word frequency analysis, generate word clouds, and perform K-means clustering on your downloaded content. All operate across your full Markdown library.

🔐 Multi-Account

Save multiple profiles from different accounts, switch between them with a single command. Each profile keeps its own auth credentials and cookies.


🏗️ Architecture

src/zhihu_cli/
├── main.py                  # Click CLI — command group hub
├── output.py                # styled terminal output (Rich)
├── content/
│   ├── handlers/            # one file per Zhihu domain
│   └── utils/               # HTML↔Markdown, ZSE v4 signing
├── creator_tools/           # income analytics + plotting
├── nlp_tools/               # word count, wordcloud, clustering
└── extensions/              # plugin system (auto-discovered)
Layer What It Does
🔐 Auth Browser Cookie + User-Agent headers from cURL paste or QR code login, cached per-profile
✍️ Signing Every Zhihu request gets auto-signed with x-zse-93 / x-zse-96 headers via ZSE v4 cipher
🌐 Requests curl_cffi impersonates Chrome's TLS fingerprint to avoid detection
📄 Extraction Prefers direct API calls; falls back to HTML page scraping with js-initialData parsing
📝 Markdown HTML → LaTeX preprocessing → recursive traversal → clean Markdown. Reverse for publishing
🔌 Extensions Drop a plugin in extensions/ with register_cli(group) — auto-discovered at startup

🧪 Extras

Optional Dependencies

pip install -e ".[nlp]"          # jieba, matplotlib, wordcloud, scikit-learn...
pip install -e ".[creator]"      # matplotlib, numpy, pandas, seaborn...
pip install -e ".[classifier]"   # torch, transformers, scikit-learn...
pip install -e ".[llm]"          # openai (zhihu agora ai, zhihu chat bot, crank)
pip install -e ".[notify]"       # desktop-notifier (zhihu chat interactive --notify)
pip install -e ".[mcp]"          # mcp (the zhihu-mcp server entry point)

Shell Completions

eval "$(python autocomp.py)"

🤝 Contributing

PRs welcome! The codebase is structured for extensibility:

  • New command? Add a file to commands/ with a register_<name>(group) function, import it in main.py.
  • New handler? Add a file to content/handlers/ — follow the existing patterns.
  • New extension? Create extensions/<name>/ with an __init__.py exposing register_cli(group).

Run the formatter before submitting:

pre-commit run --all-files
ruff check .
ruff format .

📜 License

MIT


Made with ❤️ and way too many terminal sessions.

Report a bug · Fork this repository · Star ⭐ this repo!

Metadata

Release files for zhihu-toolkit 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zhihu-toolkit 0.3.0
File Size Uploaded
zhihu_toolkit-0.3.0.tar.gz 639.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zhihu-toolkit 0.3.0
File Interpreter ABI Platform
zhihu_toolkit-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.3 MB

Release files / zhihu_toolkit-0.3.0.tar.gz

Download URL zhihu_toolkit-0.3.0.tar.gz
Size 639.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5f353aa2e9e792d4d13e54e023eb1c6f35c0e88d6808fad36ce0c87e23cb40b1
BLAKE2b-256 checksum
How to use checksums
95e8ae27c0266b317733bba75d72d45e7cddb60d65dfd4250b2342cf7b81f340
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / zhihu_toolkit-0.3.0-py3-none-any.whl

Download URL zhihu_toolkit-0.3.0-py3-none-any.whl
Size 673.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff985f65df7dc064d9ab43087917cd30fe1b8fde0f393d16af322ce47a0b7731
BLAKE2b-256 checksum
How to use checksums
6f060628e7373079132dd11098412ebad4c5f1f596eefc7bf92849d305c2f2c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page