Skip to content

Commit 332c3e3

Browse files
committed
readme
1 parent a2ddd54 commit 332c3e3

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

README.rst

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,37 @@ zhihu-python:获取知乎信息
44
介绍
55
----
66

7-
zhihu-python 采用 python2.7 编写,用来方便地获取知乎上各种内容的信息,并且可以方便地将答案备份导出为 txt 或 markdown 文件。
8-
由于知乎官方没有提供 api,所以有了此项目地存在。
7+
zhihu-python 采用 python2.7 编写,用来方便地获取知乎上各种内容的信息,并且可以方便地将答案备份导出为 txt 或 markdown 文件。由于知乎官方目前没有提供 api,所以有了此项目地存在。
8+
9+
获取某个问题下的全部回答并导出,很简单:
10+
11+
.. code-block:: python
12+
13+
from zhihu import Question
14+
15+
url = "http://www.zhihu.com/question/24269892"
16+
question = Question(url)
17+
answers = question.get_all_answers()
18+
for answer in answers:
19+
answer.to_txt()
20+
answer.to_md()
21+
22+
会在当前目录下新建text,markdown两个文件夹,并将所有txt文件保存到text文件夹,所有markdown文件保存到markdown文件夹。
23+
24+
备份某大V的全部回答,也很简单:
25+
26+
.. code-block:: python
27+
28+
from zhihu import User
29+
30+
user_url = "http://www.zhihu.com/people/jixin"
31+
user = User(user_url)
32+
answers = user.get_answers()
33+
for answer in answers:
34+
answer.to_txt()
35+
answer.to_md()
36+
37+
导出的markdown,txt文件示例请见该项目的markdown,text文件夹。当然,想要知道某大V关注了那些人,提了什么问题也不在话下,详情请见:快速开始。
938

1039
依赖
1140
-----
@@ -30,6 +59,8 @@ zhihu-python 采用 python2.7 编写,用来方便地获取知乎上各种内
3059
zhihu-python 主要文件为 zhihu.py ,配置文件为 config.ini , 将这两个文件下载到你的工作目录,并修改
3160
config.ini 文件中的 email 为你的知乎账户邮箱,修改 password 为你的知乎账户密码(用作模拟登录)。
3261

62+
**注意** :一定记得修改config.ini文件,否则无法正常使用。
63+
3364

3465
Question:获取问题信息
3566
~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)