zhihu-python
zhihu-python copied to clipboard
获取点赞人数的问题
似乎是一个bug,请您再确认一下。获取点赞人数失败,或者数字不对。
运行test.py
1。 如果某问题下只有一个回答,则 upvote = answer.get_upvote() 运行失败,报错。
比如说 answer_url = "https://www.zhihu.com/question/38214680/answer/79481584" , 报错信息: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ File "test.py", line 79, in answer_test upvote = answer.get_upvote() File "~/zhihu-python-master/zhihu.py", line 757, in get_upvote count = soup.find("span", class_="count").string AttributeError: 'NoneType' object has no attribute 'string' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2。 如果该问题下有多个回答,则获得的赞数不是这个回答的,而是紧挨着它的下一个回答的。
比如,answer_url = "https://www.zhihu.com/question/33567660/answer/79138286"
结果输出: ++++++++++++++++++++++++++++++++++++++++++++ 中国为什么不拍一部《伟大的抗日战争》呢?--石头布的回答.txt 中国为什么不拍一部《伟大的抗日战争》呢?--石头布的回答.md <zhihu.Question instance at 0x17fc950> 中国为什么不拍一部《伟大的抗日战争》呢? <zhihu.User instance at 0xbdfc68> <generator object get_voters at 0xbde0f0> 石头布 529 <---- 是下一个回答的赞数。 14537 ++++++++++++++++++++++++++++++++++++++++++++ 其中 529 是下一个回答的赞数。