Zhihu Scraping: Agent Scraping Pipeline from Bookmarks to Article Markdown

Preface

Migrating articles from Zhihu collections or columns to local notes is commonly done by writing custom scripts to call APIs or by manually copying them one by one in the browser. Incomplete API fields, expired login sessions, broken image links, and having to start over after a batch interruption can all make this process drag on. Below is an introduction to the 知乎抓取.skill (Zhihu Fetch Skill) on SkillHub (coordinates @user_9610c87f/zhihu-fetch-skill): Use a unified CLI within an Agent environment to crawl lists, save article bodies and images to disk, and optionally sync to Obsidian.

What is this

知乎抓取.skill is a community Skill designed for data analysis scenarios (SkillHub category data-analysis, current page version v2.2.0, tag requires_api_key=false). The Git repository marked by the maintainer on SkillHub is handsomestWei/zhihu-fetch-skill.

In a nutshell: Starting from links such as Zhihu collections, columns, personal profiles, and question pages, it generates an article list JSON, then batch fetches Markdown bodies and localized images. It supports multi-level fallback (API / Playwright), Cookie persistence and keep-alive, resume from breakpoints, and can write results into the “Zhihu Collections / Zhihu Notes” directory structure of Obsidian.

Core Features

The following capabilities are derived from the official introduction and the SKILL.md description within the repository. After installation, the Agent routes to various subcommands of python scripts/zhihu.py according to the documentation.

  1. Automatic Link Routing: When pasting zhihu.com / zhuanlan.zhihu.com links, use route to identify types such as collections, columns, single articles, answers, question pages, and personal homepages, then invoke the corresponding list or single-article workflow.
  2. Multi-level Fetching Fallback: Prioritizes API for article bodies; falls back to page DOM when incomplete or restricted. When Headless is detected, it can be combined with Stealth, interactive mode, etc. (listed as api / stealth / interactive in the docs).
  3. Login and Cookie: login / relogin writes cookies to the workspace zhihu_cookies.json via the browser; batch and image downloads automatically carry cookies to reduce 403 errors for columns; the script includes TTL detection and periodic keep-alive strategies.
  4. Batch Bodies and Images: batch outputs numbered Markdown, images/ directory, and _progress.json based on the list JSON; random intervals are default between articles (configurable via delay / delay_jitter).
  5. Breakpoints and Incremental Updates: If a batch is interrupted, simply rerun the same batch command to resume; the list side supports --since-last to skip unupdated entries by comparing against the workspace URL index and existing artifacts.
  6. Configurable Fetch Limits: By default, it will not crawl everything without limits; limits can be fixed via zhihu_fetch_config.json, workspace overrides, or limits --set. Command line options --max-items / --all are available.
  7. Obsidian Export (Optional): obsidian writes to {Vault}/知乎收藏/{category}/; notes generates {Vault}/知乎笔记/ in a parallel root directory without altering the mirrored original text.
  8. Run Summary: List and batch operations write a zhihu_run_summary.json to the workspace upon completion, facilitating the Agent to summarize successful, skipped, and failed items; failure lists can be written to the Vault using failures.

Installation and Activation

Install to Current Agent via SkillHub

The installation instructions provided on the SkillHub page are: Install this Skill according to the SkillHub Installation Guide. Typical CLI steps are as follows.

  1. Check if skillhub is already installed:
command -v skillhub && skillhub --version
  1. If not installed, follow the installation documentation to perform a full installation or just the CLI (the curl commands in the documentation refer to skillhub.cn).

  2. When installing the Skill, you must use --dir to point to the current Agent’s skills directory; otherwise, it defaults to ./skills/ and may not be recognized:

skillhub install @user_9610c87f/zhihu-fetch-skill --dir <skills directory>

Common paths (from SkillHub installation documentation): Cursor is ~/.cursor/skills/; Claude Code is ~/.claude/skills/; Codex is ~/.codex/skills/ or .agents/skills/ under the project. Refer to your current client’s documentation for specifics.

You can also provide the following prompt to an AI that supports Skills to have it complete the installation according to the documentation:

Please install `@user_9610c87f/zhihu-fetch-skill` based on https://skillhub.cn/install/skillhub.md.

Python Dependencies within the Skill

After installing the Skill, prepare the runtime environment in the skill root directory (containing SKILL.md and scripts/):

cd <skill root directory>/scripts
pip install -r requirements.txt
playwright install chromium

The workspace defaults to zhihu-fetch-workspace/ under the skill root (can be overridden via environment variable ZHIHU_WORKSPACE). Cookies, progress, and default outputs are stored in this directory, and should not be committed to Git.

Typical Usage

Following the steps above, it is recommended to execute in the order of “Route first, then List, then Batch, then Optional Export”. The following commands should be run in the skill root directory, with the unified entry point being python scripts/zhihu.py.

1. Login (Required for article bodies needing login)

When not logged in or if cookies are invalid:

python scripts/zhihu.py login

Use relogin if cookies need to be rewritten. Optional: Set environment variable ZHIHU_VERIFY_URL or pass a full https link after login to double-check accessibility of a specific login-required page.

python scripts/zhihu.py route "https://www.zhihu.com/collection/<id>"

Personal homepages default to the follow package (columns + articles + answers, incremental by default); single /p/ articles or answer links are handled by fetch.

3. Collection List → Batch Bodies

python scripts/zhihu.py collection "https://www.zhihu.com/collection/<id>"
python scripts/zhihu.py batch zhihu-fetch-workspace/zhihu_collection_<id>.json

The default output directory is {workspace}/zhihu_articles_{collectionId}/, containing _progress.json and images/. If interrupted, execute the same batch command again to resume.

4. Write to Obsidian (Optional)

The Vault path prioritizes command line arguments; otherwise, it reads the environment variable OBSIDIAN_VAULT:

python scripts/zhihu.py obsidian zhihu-fetch-workspace/zhihu_articles_<id> /path/to/ObsidianVault
python scripts/zhihu.py notes /path/to/ObsidianVault

Original text mirrors are in 知乎收藏/; note sections are in the parallel 知乎笔记/, without deleting mirror files.

5. View Limits and Adjust Default Count

python scripts/zhihu.py limits
python scripts/zhihu.py limits --set collection.max_items=10

If the user requests to “fetch more this time,” add --max-items or --all to the current command; if they request “make it the default for the future,” it should be written to zhihu_fetch_config.json rather than just changing the single-run parameter.

Before replying to the user, the Agent can read {workspace}/zhihu_run_summary.json to summarize the current results.

Applicable Scenarios and Notes

Who it is for: Users who need to batch archive Zhihu collections, columns, or author outputs as local Markdown; users who want the Agent to automatically select commands, handle cookies and breakpoints according to the Skill documentation; users of Obsidian who wish to save files into “Zhihu Collections / Zhihu Notes” directory structures.

Limitations and Notes:

  • Comply with Zhihu’s Terms of Service and reasonable usage frequency; batch operations include random intervals by default, but security verification pages may still be triggered, requiring relogin or troubleshooting cookies as per the documentation.
  • Without specific counts, it is subject to configuration limits and will not fetch everything by default; full fetching requires explicit --all or unlimited configuration.
  • Depends on Chromium and Python environment; UTF-8 handling instructions for Windows console encoding issues are included in the script.
  • SkillHub page statistics (as of data retrieval): Rating 100000, Downloads 8642; these may differ from numbers on third-party reposted pages. Please refer to the SkillHub Skill Page.

Conclusion

知乎抓取.skill consolidates “Identify Link → List JSON → Body & Images → Optional Obsidian” into a set of CLI conventions executable by an Agent, and handles common failure paths centered around cookies, fallbacks, and resuming from breakpoints. To enable it in clients like Cursor, install via SkillHub coordinates @user_9610c87f/zhihu-fetch-skill and configure dependencies and workspace according to the repository’s SKILL.md.

  • SkillHub API Address: https://api.skillhub.cn/user_9610c87f/zhihu-fetch-skill
  • SkillHub Page: https://www.skillhub.cn/skills/user_9610c87f/zhihu-fetch-skill
  • Git Repository: https://github.com/handsomestWei/zhihu-fetch-skill
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye