diff --git a/api.py b/api.py index aaea3a1..5ddeadd 100644 --- a/api.py +++ b/api.py @@ -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 @@ -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 diff --git a/app.py b/app.py index dd7e81c..e52f91a 100644 --- a/app.py +++ b/app.py @@ -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: