Skip to content

Commit

Permalink
修复性别不可知的 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
egrcc committed Jan 5, 2016
1 parent b1a91e9 commit 20932df
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions zhihu.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,23 @@ def get_gender(self):
"""
By Mukosame (https://github.com/mukosame)
增加获取知乎识用户的性别
"""
"""
if self.user_url == None:
print "I'm anonymous user."
return 0
return 'unknown'
else:
if self.soup == None:
self.parser()
soup = self.soup
gender = str(soup.find("span",class_="item gender").i)
if (gender == '<i class="icon icon-profile-female"></i>'):
return 'female'
else:
return 'male'
try:
gender = str(soup.find("span",class_="item gender").i)
if (gender == '<i class="icon icon-profile-female"></i>'):
return 'female'
else:
return 'male'
except:
return 'unknown'

def get_followees_num(self):
if self.user_url == None:
Expand Down

0 comments on commit 20932df

Please sign in to comment.