Skip to content

Commit 68125b8

Browse files
committed
change readme
1 parent 08f8e01 commit 68125b8

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

README.rst

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Question 代表一个问题,处理知乎问题相关操作。创建一个 Ques
9393
9494
url = "http://www.zhihu.com/question/24269892"
9595
question = Question(url)
96-
96+
9797
# 获取该问题的标题
9898
title = question.get_title()
9999
# 获取该问题的详细描述
@@ -104,15 +104,17 @@ Question 代表一个问题,处理知乎问题相关操作。创建一个 Ques
104104
followers_num = question.get_followers_num()
105105
# 获取该问题所属话题
106106
topics = question.get_topics()
107+
# 获取该问题被浏览次数
108+
visit_times = question.get_visit_times()
107109
# 获取排名第一的回答
108110
top_answer = question.get_top_answer()
109111
# 获取排名前十的十个回答
110112
top_answers = question.get_top_i_answers(10)
111113
# 获取所有回答
112114
answers = question.get_all_answers()
113-
114-
print title # 输出:现实可以有多美好?
115-
print detail
115+
116+
print title # 输出:现实可以有多美好?
117+
print detail
116118
# 输出:
117119
# 本问题相对于“现实可以多残酷?传送门:现实可以有多残酷?
118120
# 题主: 昨天看了“现实可以有多残酷“。感觉不太好,所以我
@@ -121,19 +123,14 @@ Question 代表一个问题,处理知乎问题相关操作。创建一个 Ques
121123
# 是“晒幸福“比赛。所以大家从“现实,实际”的角度出发,讲述自己的
122124
# 美好故事,让大家看看社会的冷和暖,能更加辨证地看待世界,是此
123125
# 题和彼题共同的“心愿“吧。
124-
print answers_num # 输出:2441
125-
print followers_num # 输出:26910
126+
print answers_num # 输出:2441
127+
print followers_num # 输出:26910
126128
for topic in topics:
127-
print topic , # 输出:情感克制 现实 社会 个人经历
128-
print top_answer
129-
# 输出:<zhihu.Answer instance at 0x7f8b6582d0e0>
130-
# 一个Answer类对象
131-
print top_answers
132-
# 输出:<generator object get_top_i_answers at 0x7fed676eb320>
133-
# 代表前十的Answer的生成器
134-
print answers
135-
# 输出:<generator object get_all_answer at 0x7f8b66ba30a0>
136-
# 代表所有Answer的生成器
129+
print topic, # 输出:情感克制 现实 社会 个人经历
130+
print visit_times # 输出: 该问题当前被浏览的次数
131+
print top_answer # 输出:<zhihu.Answer instance at 0x7f8b6582d0e0>(Answer类对象)
132+
print top_answers # 输出:<generator object get_top_i_answers at 0x7fed676eb320>(代表前十的Answer的生成器)
133+
print answers # 输出:<generator object get_all_answer at 0x7f8b66ba30a0>(代表所有Answer的生成器)
137134
138135
139136
Answer:获取答案信息
@@ -163,20 +160,28 @@ Answer 代表了一个答案,处理知乎答案相关操作。创建一个 Ans
163160
author = answer.get_author()
164161
# 获取该答案获得的赞同数
165162
upvote = answer.get_upvote()
163+
# 获取改该答案所属问题被浏览次数
164+
visit_times = answer.get_visit_times()
165+
# 获取所有给该答案点赞的用户信息
166+
voters = answer.get_voters()
166167
# 把答案输出为txt文件
167168
answer.to_txt()
168169
# 把答案输出为markdown文件
169170
answer.to_md()
170-
171-
print question
171+
172+
print question
172173
# <zhihu.Question instance at 0x7f0b25d13f80>
173174
# 一个Question对象
174-
print question.get_title() # 输出:现实可以有多美好?
175-
print author
175+
print question.get_title() # 输出:现实可以有多美好?
176+
print author
176177
# <zhihu.User instance at 0x7f0b25425b90>
177178
# 一个User对象
178-
print author.get_user_id() # 输出:田浩
179-
print upvote # 输出:9320
179+
for voter in voters:
180+
print voter
181+
# 一个 User 对象
182+
print author.get_user_id() # 输出:田浩
183+
print upvote # 输出:9320
184+
print visit_times # 输出: 改答案所属问题被浏览次数
180185
181186
182187
User:获取用户信息

0 commit comments

Comments
 (0)