npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wangehengyi/zhihu-cli

v1.0.0

Published

知乎 CLI - 搜索、阅读知乎内容

Readme

zhihu-cli

知乎 CLI - 通过命令行搜索、阅读知乎内容。

特性

  • 🔍 搜索知乎内容
  • 🔥 获取热榜
  • 📖 读取回答/文章
  • 👤 查看用户信息
  • 👍 点赞(Browser Relay)
  • 👣 关注用户(Browser Relay)
  • 🔐 自动从 Chrome 提取 Cookie

安装

npm install -g zhihu-cli

需要 Node.js >= 18。

快速开始

  1. 安装后运行 zhihu whoami 检查连接
  2. 设置 Cookie(见下方)
  3. 开始使用!

两种认证方式

方式一:Cookie 认证

适合命令行使用,快速便捷:

# 自动提取(需要当前用户登录过 Chrome)
zhihu login

# 手动设置
zhihu set-cookie "z_c0=xxx;d_c0=xxx;..."

⚠️ 自动提取限制:需要用当前系统用户登录过 Chrome,否则会报错 "Unable to get key for cookie decryption"。手动复制 Cookie 仍然可用。

方式二:Browser Relay(发帖功能)

适合自动化发帖,无需手动复制 Cookie:

  1. 安装 OpenClaw 扩展
  2. 在知乎页面点击扩展图标连接
  3. 直接通过语音/文字让 AI 帮你发帖

Browser Relay 发帖实现

// 关键:使用 execCommand 触发 Draft.js 输入事件
const el = document.querySelector('[contenteditable="true"]');
el.focus();
document.execCommand('insertText', false, '你的内容');

Cookie 配置文件路径

重要:手动存放 Cookie 时,请存放到以下路径:

| 系统 | 路径 | |------|------| | Windows | C:\Users\<用户名>\.openclaw\.zhihu-cookies | | Linux/Mac | ~/.openclaw/.zhihu-cookies |

获取方式:

  1. 浏览器登录知乎
  2. F12 → Application → Cookies → zhihu.com
  3. 复制 z_c0 的 Value

命令

| 命令 | 说明 | |------|------| | zhihu login | 自动从 Chrome 提取 Cookie | | zhihu whoami | 检查登录状态 | | zhihu set-cookie <cookie> | 手动设置 Cookie | | zhihu hot | 获取热榜 | | zhihu search <关键词> | 搜索内容 | | zhihu topics <关键词> | 搜索话题 | | zhihu read <链接> | 读取回答/文章 | | zhihu user <token> | 查看用户信息 | | zhihu vote <链接> | 查看 Browser Relay 点赞说明 | | zhihu follow [链接] | 查看 Browser Relay 关注说明 | | zhihu post | 查看 Browser Relay 发帖说明 |

认证方式对比

| 方式 | 优点 | 缺点 | |------|------|------| | Cookie | 快速、命令行可用 | 需手动复制 | | Browser Relay | 无需手动复制、可视化 | 需保持浏览器在线 |

依赖

  • Node.js >= 18
  • browser-cookie3 (自动提取 Cookie)
  • OpenClaw(Browser Relay 方式)

License

MIT