退乎前备份知乎回答: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)
备份已经成功,现在可以删光回答和文章了。
Metadata
Release files for zhihubackup 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zhihubackup-0.2.3.tar.gz | 17.4 kB | Without provenance | Details for zhihubackup-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zhihubackup-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for zhihubackup-0.2.3-py3-none-any.whl |
Total release size: 30.1 kB
Release files / zhihubackup-0.2.3.tar.gz
| Download URL | zhihubackup-0.2.3.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cde6d30f9a62e3522da0a074558455310dadf6425841bde6e80cbc4bd994f931
|
|
BLAKE2b-256 checksum How to use checksums |
7b5e2edeb2f677c8bec626600cf49d1691c9eb3634367d95af7a795249b115e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / zhihubackup-0.2.3-py3-none-any.whl
| Download URL | zhihubackup-0.2.3-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4380e4058a6c244b67f60d4f0038e96d05ef9e4b9fb3a9945a4ca651d619f31
|
|
BLAKE2b-256 checksum How to use checksums |
59a2734981043464d7e9fa9def6d8444a002cae1098d558e2b8daef2afd532bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for zhihubackup 0.2.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.