def _query_ans(self): #根据api优先级排序,然后访问获取答案 api_dic = { 'api.xmlm8.com': self.SearchAns_GUI_API, 'blog.vcing.top': self.BlogVCing_API, 'greasyfork': self.GreasyFork_Group_API, 'wangketiku.com': self.WangKeTiKu_API } url_order = sorted(QueryAns.api_priority.items(), key=lambda x: x[1], reverse=False) res = "" for index in range(0, len(url_order)): res = api_dic[url_order[index][0]]() if res == 0 or res == '': res = 0 continue flag = 1 for item in QueryAns.noans_flag: if item in str(res): flag = 0 res = 0 break if flag == 0: continue else: break if res != 0: send_que('courseID:' + self.courseID + ' course:' + self.course + ' que:' + self.que + ' ans:' + str(res) + '\n') else: self.no_ans_num += 1 return res
def _query_ans(self): res = self.GreasyFork_Group_API() if res == 0 or res == '' or '暂未搜到' in res: res = self.WangKeTiKu_API() if res == '' or res == 0: res = self.SearchAns_GUI_API() if res == '': res = 0 if res != 0: send_que('courseID:' + self.courseID + ' course:' + self.course + ' que:' + self.que + ' ans:' + str(res) + '\n') else: self.no_ans_num += 1 return res