def get_result_json(url,status): data = get_value(url,"/Config/result.json") if data !=None: for i in data: message = i.get(status) if message: return message return None
def handle_result(url,code): data = get_value(url,"/Config/code_message.json") if data !=None: for i in data: message = i.get(str(code)) if message: return message return None
def get_result_json(url, status): """断言方式为json时获取对应的Json数据""" data = get_value(url, "result.json") if data is not None: for i in data: message = i.get(status) # 这里需要把参数code转行为str类型 if message: return message
def handle_result_msg(url, code): """断言方式为mec时调用此函数获取对应的信息""" data = get_value(url, "code_message.json") if data is not None: for i in data: message = i.get(str(code)) # 这里需要把参数code转行为str类型 if message: return message return None
def response(self, flow): if 'imooc' in self.request_url or 'mukewang' in self.request_url: response_data = flow.response host = self.request_url.split(".com") #base_url = host[0] url = host[1] if "?" in host[1]: url = url.split("?")[0] data = json.dumps(get_value(url)) response_data.set_text(data)
def handle_result(url, code): data = get_value(url, "/Config/code_message.json") # print('---->',code,'---->',type(code)) # print(data) # [{'1001': '登陆成功'}, {'1002': '用户名错误'}, {'1003': '密码错误'}] # 这里为什么返回None呢 if data != None: for i in data: message = i.get(str(code)) if message: return message return None
def get_result_json(url, status): """ 検証用のjsonデータを取得 :param url: ターゲットになるjsonデーターを取得のキー :return: """ data = get_value(url, "/Config/result.json") if data != None: for i in data: message = i.get(status) if message: return message return None
def handle_result(filepath, code, config="config"): ''' * @name: Tommy * @msg: 获取本地errorMsg的json文件 * @param {url:请求url,filepath:json路径,code:errorCode值} * @return {返回对应的errorMsg或None} ''' res_list = get_value(config, filepath) if res_list is not None: for item in res_list: message = item.get(str(code)) if message is not None: return message return None
def handel_result(url, code) -> any: """ 予測結果を取得 :param url: configの内容を取得用のキー :param code: 実際サーバからのリスポンスのエラーcode :return: 状態メッセージを返す """ data = get_value(url, "/Config/code_message.json") if data != None: for i in data: message = i.get(str(code)) if message: return message return None
def response(self, flow): if 'imooc' in self.request_url or 'mukewang' in self.request_url: response_data = flow.response host = self.request_url.split(".com") base_url = host[0] url = host[1] #/api3/getbanneradvertver2 #api3/getbanneradvertver2?aaa=sss if "?" in host[1]: url = url.split("?")[0] print("====>", url) data = json.dumps(get_value(url)) print("----->data:", data) response_data.set_text(data) '''
def run_main(self, method, url, data): return get_value(url) base_url = get_ini.get_value('host') if 'http' not in url: url = base_url + url if method == "get": res = self.send_get(url, data) else: res = self.send_post(url, data) try: res = json.loads(res) except: print('这是个text呀') return res
def run_main(self, method, url, data): """ 执行方法,传递method,url,data参数 """ return get_value("api1") base_url = handle_ini.get_value('host') if 'http' in base_url: if url != None: url = base_url + url print(url) else: url = base_url if method == 'get': res = self.send_get(url, data) else: res = self.send_post(url, data) try: res = json.loads(res) except: print("这个结果是一个text") return res
sys.path.append(base_path) from Util.handle_json import get_value import json_tools import json def cmp(src_data,dst_data): if isinstance(src_data, dict): """若为dict格式""" for key in dst_data: if key not in src_data: print("src不存在这个key") for key in src_data: if key in dst_data: thiskey = key """递归""" cmp(src_data[key], dst_data[key]) else: src_data[key] = ["dst不存在这个key"] elif isinstance(src_data, list): """若为list格式""" if len(src_data) != len(dst_data): print("list len: '{}' != '{}'".format(len(src_data), len(dst_data))) for src_list, dst_list in zip(sorted(src_data), sorted(dst_data)): """递归""" cmp(src_list, dst_list) else: if str(src_data) != str(dst_data): print(src_data) dict1 = get_value("api3/newcourseskill") dict2 = get_value("api3/getbanneradvertver2") cmp(dict1,dict2)