Skip to content

Commit 0d01e2a

Browse files
committed
Merge pull request egrcc#31 from LuoZijun/patch-11
修正JSON解析问题
2 parents 130401c + bf62c76 commit 0d01e2a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

auth.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,14 @@ def upload_form(form):
139139
raise NetworkError(u"表单上传失败!")
140140

141141
if r.headers['content-type'].lower() == "application/json":
142-
result = r.json()
142+
try:
143+
# 修正 justkg 提出的问题: https://github.com/egrcc/zhihu-python/issues/30
144+
result = json.loads(r.content)
145+
except Exception as e:
146+
Logging.error(u"JSON解析失败!")
147+
Logging.debug(e)
148+
Logging.debug(r.content)
149+
result = {}
143150
if result["r"] == 0:
144151
Logging.success(u"登录成功!" )
145152
return {"result": True}

0 commit comments

Comments
 (0)