Command-line tool for searching, reading, and interacting with Zhihu (知乎). Supports hot topics, content search, article reading, user info, and Browser Relay...
A CLI tool for interacting with Zhihu (知乎) content.
# Install globally
npm install -g zhihu-cli
# Or use npx
npx zhihu-cli <command>
| Command | Description |
|---|---|
zhihu login | Auto-extract cookies from Chrome |
zhihu whoami | Check login status |
zhihu set-cookie <cookie> | Set cookie manually |
zhihu hot | Get hot topics |
zhihu search <keyword> | Search content |
zhihu topics <keyword> | Search topics |
zhihu read <url> | Read answer/article |
zhihu user <token> | Get user info by url_token |
zhihu vote <url> | Browser Relay vote instructions |
zhihu follow [url] | Browser Relay follow instructions |
zhihu post | Browser Relay post instructions |
zhihu login
Opens Chrome and extracts cookies automatically.
zhihu set-cookie "your_zhihu_cookie_string"
Some operations (vote, follow, post) require Browser Relay due to API limitations.
zhihu vote <answer_url>
Then click the vote button in browser or use JS:
const btn = document.querySelector('button[class*="VoteButton"]');
if (btn) btn.click();
zhihu follow <user_url>
Or click the follow button in browser.
Zhihu has restricted API access for:
Read operations (search, hot, read, user) work via API.
# Get hot topics
zhihu hot
# Search for Python tutorials
zhihu search Python教程
# Read an answer
zhihu read https://www.zhihu.com/question/123456/answer/789012
# Get user info
zhihu user lightislost
# Check login
zhihu whoami
~/.zhihu-cookieZIP package — ready to use