Skip to content

Commit

Permalink
Merge pull request dataabc#401 from minami9/master
Browse files Browse the repository at this point in the history
fix: when uid==1 then crash
  • Loading branch information
dataabc committed Dec 14, 2021
2 parents 3b9f862 + 0061c7c commit 7730543
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 4 additions & 5 deletions weibo_spider/parser/info_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def extract_user_info(self):
if i.split(':', 1)[0] in zh_list:
setattr(user, en_list[zh_list.index(i.split(':', 1)[0])],
i.split(':', 1)[1].replace('\u3000', ''))

if self.selector.xpath(
"//div[@class='tip'][2]/text()")[0] == u'学习经历':
experienced = self.selector.xpath("//div[@class='tip'][2]/text()")
if experienced and experienced[0] == u'学习经历':
user.education = self.selector.xpath(
"//div[@class='c'][4]/text()")[0][1:].replace(
u'\xa0', u' ')
Expand All @@ -46,8 +46,7 @@ def extract_user_info(self):
user.work = self.selector.xpath(
"//div[@class='c'][5]/text()")[0][1:].replace(
u'\xa0', u' ')
elif self.selector.xpath(
"//div[@class='tip'][2]/text()")[0] == u'工作经历':
elif experienced and experienced[0] == u'工作经历':
user.work = self.selector.xpath(
"//div[@class='c'][4]/text()")[0][1:].replace(
u'\xa0', u' ')
Expand Down
3 changes: 3 additions & 0 deletions weibo_spider/parser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def to_video_download_url(cookie, video_page_url):

def string_to_int(string):
"""字符串转换为整数"""
if len(string) == 0:
logger.warning("string to int, the input string is empty!")
return 0
if isinstance(string, int):
return string
elif string.endswith(u'万+'):
Expand Down

0 comments on commit 7730543

Please sign in to comment.