zhihu_crawler
本程序支持关键词搜索、热榜、用户信息、回答、专栏文章、评论等信息的抓取
项目目录
__init__.py 为程序的对外统一入口
constants.py 常量
exceptions.py 自定义异常
extractors.py 数据清洗
page_iterators.py 简单的页面处理
zhihu_scraper.py 页面请求、cookie设置
zhihu_types.py 类型提示、检查。项目自定义类型
注意事项: 项目内有部分异步操作,在模块引用之前需要使用猴子补丁; 同时该项目没有对ip限制、登录做针对性处理
安装
pip install zhihu_crawler
使用
if __name__ == '__main__':
# 设置代理; 如采集量较大,建议每次请求都切换代理
set_proxy({'http': 'http://127.0.0.1:8125', 'https': 'http://127.0.0.1:8125'})
# 设置cookie
set_cookie({'d_c0': 'AIBfvRMxmhSPTk1AffR--QLwm-gDM5V5scE=|1646725014'})
# 搜索采集使用案例:
for info in search_crawl(key_word='天空', count=10):
print(info)
# 可传入data_type 指定搜索类型
for info in search_crawl(key_word='天空', count=10, data_type='answer'):
print(info)
# 用户信息回答列表使用案例(采集该用户信息及50条回答信息,每条回答包含50条评论):
for info in user_crawler('wo-men-de-tai-kong',
answer_count=50,
comment_count=50
):
print(info)
# 用户信息提问列表使用案例(采集该用户信息及10条问题信息,每条问题包含10条回答,每条回答包含50条评论):
for info in user_crawler('wo-men-de-tai-kong',
question_count=10,
drill_down_count=10,
comment_count=50):
print(info)
# 热点问题采集使用案例
# 采集 前10个问题, 每个问题采集10条回答
for info in hot_questions_crawl(question_count=10, drill_down_count=10):
print(info)
# 可传入period 指定热榜性质。如小时榜、日榜、周榜、月榜
# 传入domains 采集指定主题的问题
for info in hot_questions_crawl(question_count=10, period='day', domains=['1001', 1003]):
print(info)
Metadata
Release files for zhihu-crawler 0.0.2
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 |
|---|---|---|---|---|
| zhihu_crawler-0.0.2.tar.gz | 3.1 MB | Without provenance | Details for zhihu_crawler-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zhihu_crawler-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for zhihu_crawler-0.0.2-py3-none-any.whl |
Total release size: 7.5 MB
Release files / zhihu_crawler-0.0.2.tar.gz
| Download URL | zhihu_crawler-0.0.2.tar.gz |
|---|---|
| Size | 3.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
917fd4c687cd0cb01b3c95ad240d386f06ac776aa6fdeec5b44916398328a3b8
|
|
BLAKE2b-256 checksum How to use checksums |
98d7abf98bcb4c21d91c6bfc711f4239d28ea9311bd61102f3ed00ae0110c8c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.7.9
|
Release files / zhihu_crawler-0.0.2-py3-none-any.whl
| Download URL | zhihu_crawler-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f90144d2ed2668f785889a77908fc518b4cd6857aeef173bf44686ea7f4586e
|
|
BLAKE2b-256 checksum How to use checksums |
0f306bf5a1e8d490df3b1f0fddcfcdf7bf5c68da7080c2ba965eee4418839548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.7.9
|
Security for zhihu-crawler 0.0.2
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.