Skip to content

question.get_top_i_answers() 和 question.get_all_answers() 获取答案失败 #61

Description

@turfT

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 `

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions