Skip to main content

Backup your Zhihu contents before quitting Zhihu.

Project description

退乎前备份知乎回答:zhihubackup

每个知乎答主都有退乎的梦想,但退乎前如果删光回答,则十分可惜。因此,我用Python写了60行的脚本,可以在退乎前备份自己的所有回答和文章,以免事后后悔。

安装

pipx安装zhihubackup到独立环境中:

pip install pipx
pipx install zhihubackup

使用

2024年7月起,知乎添加了如下所示的验证操作:

{"error": {"need_login": true, "redirect": "https://www.zhihu.com/account/unhuman?type=S6E3V1&need_login=true", "code": 40352, "message": "系统监测到您的网络环境存在异常,为保证您的正常访问,请点击下方验证按钮进行验证。在您验证完成前,该提示将多次出现。"}}

因此需要从浏览器中手动获取zhihu.com的cookie: Chrome获取Cookie Edge获取Cookie

将获取的cookie设置为环境变量:

export ZHUHU_COOKIE="q_c1=...; ...; osd=..."

假如你是@贱贱,你的id是splitter,那么可以执行命令:

zhihubackup splitter

静等一段时间。运行结束后,可以看到产生了名为splitter的文件夹:

- splitter
|- answer   (842 files)
|- article  (101 files)
|- pin      (3214 files)
|- question (57 files)

备份已经成功,现在可以删光回答和文章了。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zhihubackup-0.2.3.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

zhihubackup-0.2.3-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file zhihubackup-0.2.3.tar.gz.

File metadata

  • Download URL: zhihubackup-0.2.3.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for zhihubackup-0.2.3.tar.gz
Algorithm Hash digest
SHA256 cde6d30f9a62e3522da0a074558455310dadf6425841bde6e80cbc4bd994f931
MD5 7d8675068e11624ce08545d045331433
BLAKE2b-256 7b5e2edeb2f677c8bec626600cf49d1691c9eb3634367d95af7a795249b115e5

See more details on using hashes here.

File details

Details for the file zhihubackup-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: zhihubackup-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for zhihubackup-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e4380e4058a6c244b67f60d4f0038e96d05ef9e4b9fb3a9945a4ca651d619f31
MD5 3363aae8fe9273ef6faf9b9c68f5665c
BLAKE2b-256 59a2734981043464d7e9fa9def6d8444a002cae1098d558e2b8daef2afd532bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page