Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
fix cxmooc and www150
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu committed Sep 17, 2019
1 parent e7e044e commit 96705b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def cxmooc_tool(sess: requests.Session,
sess = requests.Session()

# 接口
url = "https://blog.icodef.com:8081/v2/answer"
url = "https://cx.icodef.com/v2/answer"

# 接口参数
index = yield
Expand Down Expand Up @@ -296,9 +296,11 @@ async def www150s(sess: requests.Session,
res = res.json()
answer = []
temp = {}
temp['topic'] = res['title']
temp['correct'] = res['answer']
if temp['topic'] != "查无此题,请您换一道题查询!":
for each in res:
temp['topic'] = each['title']
temp['correct'] = each['answer']
if temp['topic'] == "查无此题,请您换一道题查询!":
break
answer.append(temp)
logging.info("Yield question %s: %s" % (i+1, answer))
index = yield answer
Expand Down
5 changes: 4 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ async def search(self, frame_list):
for generator in generator_list.keys():
label.insert(END, f"查询中。。。使用源{generator}\n")
label.configure(state="disable")
result = await generator_list[generator].asend(i)
try:
result = await generator_list[generator].asend(i)
except Exception as e:
logging.error(repr(e))
label.configure(state="normal")
if result and result[0]['correct']:
for answer in result:
Expand Down

0 comments on commit 96705b7

Please sign in to comment.