Skip to content

Commit 7b50472

Browse files
committed
修复 issue 10 中的 bug
1 parent 38f175d commit 7b50472

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

zhihu.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ def get_all_answers(self):
305305

306306
answer_soup = BeautifulSoup(answer_list[j])
307307

308+
if answer_soup.find("div", class_=" zm-editable-content clearfix") == None:
309+
continue
310+
308311
author = None
309312
if answer_soup.find("h3", class_="zm-item-answer-author-wrap").string == u"匿名用户":
310313
author_url = None
@@ -315,7 +318,10 @@ def get_all_answers(self):
315318
author_url = "http://www.zhihu.com" + author_tag["href"]
316319
author = User(author_url, author_id)
317320

318-
count = answer_soup.find("span", class_="count").string
321+
if answer_soup.find("span", class_="count") == None:
322+
count = answer_soup.find("a", class_="zm-item-vote-count").string
323+
else:
324+
count = answer_soup.find("span", class_="count").string
319325
if count[-1] == "K":
320326
upvote = int(count[0:(len(count) - 1)]) * 1000
321327
elif count[-1] == "W":

0 commit comments

Comments
 (0)