Skip to content

Commit

Permalink
Bugfix #13: Handle KeyError when login failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodour committed Feb 1, 2019
1 parent 1bdb940 commit 6642591
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion weibo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def __init__(self, target_url):
# 目标数据
self.logger.info(Fore.BLUE + target_url)
self.target = WeiboApi.fetch_user_info(target_url)
self.uid, self.name = self.target['oid'], self.target['onick']
try:
self.uid, self.name = self.target['oid'], self.target['onick']
except KeyError as err:
message = '获取 %s 失败,可能原因为 Cookies 过期,或 API 发生变化。' % err
self.logger.error(Fore.RED + message)
exit(-1)

# 本地预处理
self.root = self.__init_folder()
Expand Down

0 comments on commit 6642591

Please sign in to comment.