You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
q=question.get_top_i_answers(20)
for i in q:
print i`
`<zhihu.Answer instance at 0x10441a1b8>
<zhihu.Answer instance at 0x115b378c0>
<zhihu.Answer instance at 0x1177319e0>
<zhihu.Answer instance at 0x1150dab00>
<zhihu.Answer instance at 0x117833b90>
<zhihu.Answer instance at 0x11587d368>
<zhihu.Answer instance at 0x1159a6e18>
<zhihu.Answer instance at 0x11698bf80>
<zhihu.Answer instance at 0x115614c68>
<zhihu.Answer instance at 0x1174d1170>
IndexError Traceback (most recent call last)
in ()
4 print question.get_answers_num()
5 q=question.get_top_i_answers(20)
----> 6 for i in q:
7 print i
/Users/traveltao/Desktop/zhihu-python-master/zhihu.py in get_top_i_answers(self, n)
460 j = 0
461 answers = self.get_all_answers()
--> 462 for answer in answers:
463 j = j + 1
464 if j > n:
同出现该问题,上述两种方法都试过了,都只能获取开头前十个问题然后报错
报错如下:
if soup.find_all("div", class_="zm-item-answer")[j].find("span", class_="count") == None:
IndexError: list index out of range
question.get_top_i_answers() 和 question.get_all_answers() 都只能获得10 个回答了,测试了几个问题,包括test 中的 http://www.zhihu.com/question/24269892
`url = "http://www.zhihu.com/question/24269892"
question = Question(url)
print question.get_answers_num()
q=question.get_top_i_answers(20)
for i in q:
print i`
`<zhihu.Answer instance at 0x10441a1b8>
<zhihu.Answer instance at 0x115b378c0>
<zhihu.Answer instance at 0x1177319e0>
<zhihu.Answer instance at 0x1150dab00>
<zhihu.Answer instance at 0x117833b90>
<zhihu.Answer instance at 0x11587d368>
<zhihu.Answer instance at 0x1159a6e18>
<zhihu.Answer instance at 0x11698bf80>
<zhihu.Answer instance at 0x115614c68>
<zhihu.Answer instance at 0x1174d1170>
IndexError Traceback (most recent call last)
in ()
4 print question.get_answers_num()
5 q=question.get_top_i_answers(20)
----> 6 for i in q:
7 print i
/Users/traveltao/Desktop/zhihu-python-master/zhihu.py in get_top_i_answers(self, n)
460 j = 0
461 answers = self.get_all_answers()
--> 462 for answer in answers:
463 j = j + 1
464 if j > n:
/Users/traveltao/Desktop/zhihu-python-master/zhihu.py in get_all_answers(self)
342
343 is_my_answer = False
--> 344 if soup.find_all("div", class_="zm-item-answer")[j].find("span", class_="count") == None:
345 my_answer_count += 1
346 is_my_answer = True
IndexError: list index out of range `
The text was updated successfully, but these errors were encountered: