Skip to content

Commit a98c731

Browse files
committed
修复 issue egrcc#44 中的 bug
1 parent 16b229c commit a98c731

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

zhihu.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def get_all_answers(self):
177177
else:
178178
error_answer_count = 0
179179
my_answer_count = 0
180-
for i in xrange((answers_num - 1) / 50 + 1):
180+
for i in xrange((answers_num - 1) / 20 + 1):
181181
if i == 0:
182-
for j in xrange(min(answers_num, 50)):
182+
for j in xrange(min(answers_num, 20)):
183183
if self.soup == None:
184184
self.parser()
185185
soup = BeautifulSoup(self.soup.encode("utf-8"))
@@ -234,9 +234,9 @@ def get_all_answers(self):
234234
else:
235235
post_url = "http://www.zhihu.com/node/QuestionAnswerListV2"
236236
_xsrf = self.soup.find("input", attrs={'name': '_xsrf'})["value"]
237-
offset = i * 50
237+
offset = i * 20
238238
params = json.dumps(
239-
{"url_token": int(self.url[-8:-1] + self.url[-1]), "pagesize": 50, "offset": offset})
239+
{"url_token": int(self.url[-8:-1] + self.url[-1]), "pagesize": 20, "offset": offset})
240240
data = {
241241
'_xsrf': _xsrf,
242242
'method': "next",
@@ -250,7 +250,7 @@ def get_all_answers(self):
250250
r = requests.post(post_url, data=data, headers=header)
251251

252252
answer_list = r.json()["msg"]
253-
for j in xrange(min(answers_num - i * 50, 50)):
253+
for j in xrange(min(answers_num - i * 20, 20)):
254254
soup = BeautifulSoup(self.soup.encode("utf-8"))
255255

256256
answer_soup = BeautifulSoup(answer_list[j])

0 commit comments

Comments
 (0)