def __init__(self): self.run_method = RunMethod() self.data = GetData() self.containt = CommonUtile() self.email = Mailer() self.log = UserLog() self.logger = self.log.get_log()
def __init__(self): self.json_file = "/Users/mac/Desktop/测试资料/蜗牛家产品线/woniujia_cc_jiekou/woniujia_cc_jiekou_git/woniujia_cc_project/dataconfig/request_pram.json" self.sheet_name = "客户模块" self.sheet_id = 5 self.data = GetData(self.json_file, self.sheet_name, self.sheet_id) self.run_method = RunMethod() self.util = CommonUtil() self.email = SendEmail()
def __init__(self, json_file, sheet_name, sheet_id): # self.excel_file = excel_file self.json_file = json_file self.sheet_name = sheet_name self.sheet_id = sheet_id self.data = GetData(self.json_file, self.sheet_name) self.run_method = RunMethod() self.util = CommonUtil() self.email = SendEmail()
def __init__(self): read_conf = ReadConfig() # 邮件发送开关 self.is_on = read_conf.get_email_config_var('on_off') self.run_method = RunMethod() self.data = GetData() self.public_util = PublicUtil() self.headers_and_cookies = OperationJson() self.cookies = self.headers_and_cookies.get_key_words("cookie") self.headers = self.headers_and_cookies.get_key_words("header")
def __init__(self, json_file, sheet_name, sheet_id, sql_base=None): self.json_file = json_file self.sheet_name = sheet_name self.sheet_id = sheet_id self.sql_base = sql_base self.data = GetData(self.json_file, self.sheet_name) self.run_method = RunMethod() self.util = CommonUtil() self.email = SendEmail()
def run_dependdent(self): run_method = RunMethod() row = int(self.opera_excel.get_rows_num(self.case_id)) request_data = self.data.get_data_for_json(row) cookie = self.data.is_cookie(row) method = self.data.get_request_method(row) url = self.data.get_url(row) res = run_method.run_main(method, url, request_data, cookie) return res
def run_dependent(self): run_method = RunMethod() row_num = self.op_excel.get_row_num(self.case_id) request_data = self.data.get_data_for_json(row_num) # header = self.data.get_header(row_num) method = self.data.get_request_method(row_num) url = self.data.get_url(row_num) res = run_method.run_main(method, url, request_data) return json.loads(res)
def run_denpendent(self): run_method = RunMethod() row_num = self.opera_excel.get_row_num(self.case_id) request_data = self.data.get_data_for_json(row_num) header = self.data.is_header(row_num) method = self.data.get_request_method(row_num) url = self.data.get_url(row_num) res = run_method.run_main(method, url, request_data, header) return res
def run_dependent(self): run_merhod = RunMethod() row_num = self.Open_excel.get_row_num(self.case_id) request_data = self.data.get_data_json(row_num) header = self.data.get_is_hander(row_num) method = self.data.get_request_method(row_num) url = self.data.get_request_url(row_num) res = run_merhod.run_main(method, url, request_data, header) return json.loads(res)
class RunMain: def __init__(self): self.run_m = RunMethod() self.handle_h = HandleHeader() def handle_data(self): config_d = ConfigData(self.data) self.case_id = config_d.get_case_id() self.case_name = config_d.get_case_name() self.url = config_d.get_url() self.method = config_d.get_method() self.header_info = config_d.get_header_info() self.run_data = config_d.get_run_data() self.is_run = config_d.get_is_run() self.depend_case_id = config_d.get_depend_case_id() self.depend_response_key = config_d.get_depend_reponse_key() self.depend_request_key = config_d.get_depend_request_key() self.is_connect = config_d.get_is_connect() self.is_connect_db = config_d.get_is_connect_db() self.is_mock = config_d.get_is_mock() self.expect = config_d.get_expect() def run_main(self, data): self.data = data self.handle_data() header = self.handle_h.handle_h(self.header_info) if self.is_run: if self.depend_case_id: h = HandleDepend() self.run_data = h.replace_data(data) if self.run_data: self.run_data = handle(self.run_data) if header[1]: #发送带cookie res = self.run_m.send_request(method=self.method, url=self.url, data=self.run_data, header=header[0], cookie=header[1]) else: res = self.run_m.send_request(method=self.method, url=self.url, data=self.run_data, header=header[0]) #写入cookie if header[2]: self.handle_h.write_cookie(res) compare = Compare() config_d1 = ConfigData(self.data) print(self.expect, res.text) if compare.comp(self.expect, res.text): print("pass") config_d1.write_result("pass", self.case_id) else: print("fail") config_d1.write_result("fail", self.case_id)
class RunTest: def __init__(self): self.run_method = RunMethod() self.data = GetData() self.common = CommonUtil() self.mail = SendEmail() self.opera_json = OperationJson('../json_config/cookie.json') def go_on_run(self): logger.info("*************** 开始执行用例 ***************") res = None pass_count = [] fail_count = [] request_data = {} rows_count = self.data.get_case_lines() try: for i in range(1, rows_count): is_run = self.data.get_is_run(i) if is_run: url = self.data.get_url(i) method = self.data.get_request_method(i) data = json.dumps(self.data.get_data_for_json(i)) expect = self.data.get_expect_data(i) header = self.data.is_cookie(i) depend_case = self.data.is_depend(i) if depend_case != None: self.depend_data = DependDentData(depend_case) # 相应数据 depend_response_data = self.depend_data.get_data_for_key( i) # 获取依赖的key depend_key = self.data.get_depend_field(i) request_data[depend_key] = depend_response_data if header == 'write': res = self.run_method.run_main(method, url, data) opera_header = OperationHeader() opera_header.write_cookie() if header != 'write': cookie = self.opera_json.get_data('JSESSIONID') cookies = {"JSESSIONID": cookie} cookies = json.dumps(cookies) res = self.run_method.run_main(method=method, url=url, data=data, cookies=cookies) if self.common.is_contain(expect, res): self.data.write_result(i, 'pass') pass_count.append(i) else: self.data.write_result(i, 'fail') fail_count.append(i) self.mail.send_main(pass_count, fail_count) except requests.exceptions.ConnectionError: print('连接错误') logger.info("*************** 结束执行用例 ***************") return res
class RunTest: def __init__(self): self.run_method = RunMethod() self.data = GetData() self.com_util = CommonUtil() self.send_email = SendEmail() def go_on_run(self): pass_count = [] fail_count = [] rows_count = self.data.get_case_lines() for i in range(1,rows_count): is_run = self.data.get_is_run(i) print '----->is_run: ',is_run if is_run: url = self.data.get_request_url(i) method = self.data.get_method(i) request_data = self.data.get_request_data_for_json(i) header = self.data.get_is_header(i) depend_case = self.data.get_depend_case(i) expect = self.data.get_expect(i) print '----->depend_case: ',depend_case if depend_case != '': dependdata = DependData(depend_case) depend_respone_data = dependdata.get_data_for_key(i) depend_key = self.data.get_depend_field(i) request_data[depend_key] = depend_respone_data print '----->header: ',header if header == 'write': op_header = OperationHeader(url, method, request_data) op_header.write_cookie() res = self.run_method.run_main(url, method, request_data) elif header == 'yes': op_json = OperationJson('../data/cookies.json') t_key = op_json.get_data('key') cookies = { "id":t_key } res = self.run_method.run_main(url, method, request_data, cookies) else: res = self.run_method.run_main(url, method, request_data) #print u'----The %s case\' result is:----\n%s' %(i, res) #print '------------------------' if self.com_util.is_contain(expect, res): self.data.write_resule(i, 'Pass') pass_count.append(i) else: self.data.write_resule(i, res) fail_count.append(i) print '--->over' self.send_email.send_main(pass_count, fail_count)
def run_depend(self): run_method = RunMethod() row_num = self.operEx.get_row_num(self.case_id) url = self.data.get_request_url(row_num) method = self.data.get_method(row_num) request_data = self.data.get_request_data_for_json(row_num) header = self.data.get_is_header(row_num) if header == 'yes': res = run_method.run_main(url, method, request_data, header) else: res = run_method.run_main(url, method, request_data) return json.loads(res)
class RunTest: def __init__(self): self.run_method = RunMethod() self.data = GetData() self.is_contain = CommonUtil() # 执行程序 def go_no_run(self, i): rows_conut = self.data.get_case_lines() # 获取行数 is_run = self.data.get_is_run(i) print(is_run) if is_run: url = self.data.get_url(i) method = self.data.get_request_way(i) # 获取请求的方法 request_data = self.data.get_json_data(i) # 获取请求数据 data_type = self.data.get_data_type(i) print(data_type) cookie = self.data.get_is_cookies(i) # 获取cookies expect = self.data.get_expect(i) # 获取预期结果 result = self.data.get_result(i) depend_case = self.data.get_depend_case_id(i) # 获取依赖的caseid if depend_case is not None: # 获取替换请求字段 depend_key = self.data.get_depned_key(i) # 获取依赖的响应数据 self.depend_data = DependData(depend_case) depend_response_data = self.depend_data.get_depned_value(i) split = len(depend_key.split(">")) # 切割替换的字段 # 根据请求字段的个数替换 for y in range(0, split): re = depend_key.split(">") request_data[re[y]] = depend_response_data[y] if cookie == 'write': res = self.run_method.run_main(method, url, request_data) op_cookie = OperationCookie(res) # 获取cookies op_cookie.write_cookie() # 写入cookies elif cookie == 'yes': get_cookies = OperationJson('../data/scm-cookies.json') cooki = get_cookies.get_data('SESSION') cookies = {"SESSION": cooki} res = self.run_method.run_main(method, url, request_data, cookies, data_type) else: res = self.run_method.run_main(method, url, request_data) if self.is_contain.is_contain(expect, res): self.data.write_data(i, 'pass') print(res) else: self.data.write_data(i, 'fail') print(res)
class RunTest(object): def __init__(self): self.run_method = RunMethod() self.data = GetData() self.common_util = CommonUtil() self.send_email = SendEmail() def run(self): res = None pass_count = [] fail_count = [] rows_count = self.data.get_case_lines() for i in range(1, rows_count): run = self.data.get_run(i) if run: url = self.data.get_url(i) request_method = self.data.get_request_method(i) request_data = self.data.get_data_for_json(i) expect = self.data.get_expect(i) print(expect) header = self.data.get_header(i) # case_depend = self.data.get_case_depend(i) # if case_depend != None: # self.depend_data = DependentData(case_depend) # depend_response_data = self.depend_data.get_data_for_key(i) # depend_key = self.data.get_depend_response_data(i) # request_data[depend_key] = depend_response_data if header == 'write': res = self.run_method.run_main(request_method, url, request_data) op_header = OperationHeader(res) op_header.write_cookie() elif header == 'yes': op_json = OperationJson('../dataconfig/cookie.json') cookie = op_json.get_data('apsid') cookies = {'apsid': cookie} res = self.run_method.run_main(request_method, url, request_data, cookies) else: res = self.run_method.run_main(request_method, url, request_data) print(res) if self.common_util.is_contain(expect, res) == 1: self.data.write_result(i, 'pass') pass_count.append(i) print(pass_count) else: self.data.write_result(i, res) fail_count.append(i) print(fail_count) self.send_email.send_main(pass_count, fail_count)
class RunTest: def __init__(self): self.run_method = RunMethod() self.data = GetData() self.comment_util = CommentUtil() self.send_mail = SendEmail() # 程序执行 def go_on_run(self): count = self.data.get_case_lines() pass_count = [] fail_count = [] for i in range(1, count): is_run = self.data.get_is_run(i) print(i) if is_run is True: url = self.data.get_request_url(i) method = self.data.get_request_method(i) data = self.data.get_data_for_json(i) header = self.data.is_header(i) expect = self.data.get_expect_data(i) # 如果用需要查询数据库则用下面这条 # expect = self.data.get_expect_data_for_mysql(i) depend_case = self.data.is_depend(i) if depend_case is not None: depend_data = DependentData(depend_case) # 获取依赖的相应数据 depend_response_data = depend_data.get_data_for_key(i) # 获取依赖的key depend_key = self.data.get_depend_filed(i) data[depend_key] = depend_response_data if header == 'write': res = self.run_method.run_main(method, url, data) op_header = OperationHerader(res) op_header.write_cookie() elif header == 'yes': op_json = OperationJson('../dataconfig/cookie.json') new_header = op_json.new_header() res = self.run_method.run_main(method, url=url, data=data, header=new_header) else: res = self.run_method.run_main(method, url, data) res = self.comment_util.remate_data(res) # 字符串比较用is_contain,字典比较用is_equal_dict result = self.comment_util.is_contain(expect, res) if result is True: self.data.write_value(i, 'pass') pass_count.append(i) else: self.data.write_value(i, res) fail_count.append(i)
class LoginApi: def __init__(self): self.data = GetData( "/Users/mac/Desktop/测试资料/python_jiekou_auto/python_jiekou_git/Demo/dataconfig/login.xls" ) self.run_method = RunMethod() self.util = CommonUtil() def go_run_login(self): # 获取用例行数 row_count = self.data.get_case_line() #循环用例 for i in range(1, row_count): #获取isrun,是否运行该用例 is_run = self.data.get_is_run(i) if is_run: #获取url url = self.data.get_url(i) request_type = self.data.get_request_type(i) header = self.data.get_header(i) request_data = self.data.get_data_for_json(i) response = self.run_method.run_main(request_type, url, request_data, header) print("返回结果:", response) expect_res = self.data.get_except(i) print("期望结果:", expect_res) if self.util.is_contain(expect_res, response): self.data.write_result(i, "测试通过") print("测试通过") else: self.data.write_result(i, "测试失败") print("测试失败") return response
class RunTest(object): def __init__(self): self.common_util = CommonUtil() self.send_email = SendEmail() self.connect_db = OperationMySQL() self.run_method = RunMethod() self.op_json = OperationJson() def run(self): res = None pass_count = [] fail_count = [] rows_count = self.connect_db.get_count() print(rows_count) for i in range(0, rows_count): run = self.connect_db.search('run', i) if run: url = self.connect_db.search('url', i) request_method = self.connect_db.search('request_method', i) request_data = self.op_json.get_data( self.connect_db.search('request_data', i)) expect = self.connect_db.search('expect', i) print(expect) res = self.run_method.run_main(request_method, url, request_data) print(res) if self.common_util.is_contain(expect, res) == 1: self.connect_db.write('pass', i + 1) pass_count.append(i + 1) print(pass_count) else: self.connect_db.write(res, i + 1) fail_count.append(i + 1) print(fail_count) self.send_email.send_main(pass_count, fail_count)
class DataDepend: def __init__(self): self.data = GetData() self.run_method = RunMethod() #根据case_id获取行号 def get_row_count(self,case_id,col): row_count = 0 case_datas = self.data.get_case_id(col) for id in case_datas: if case_id in id: return row_count row_count += 1 #获取返回值 def get_response_data(self,case_id,col): row_count = self.get_row_count(case_id,col) url = self.data.request_url(row_count) is_run = self.data.is_run(row_count) request_way = self.data.get_method_way(row_count) request_data = self.data.get_method_data_depend(row_count) if is_run: res = self.run_method.run_main(request_way,url,request_data) return res #获取依赖的数据值 def get_depend_data(self,row,case_id,col): depend_data = self.data.get_response_depend_data(row) response = self.get_response_data(case_id,col) jsonpath_expr = parse(depend_data) res_data = jsonpath_expr.find(response) return [match.value for match in res_data]
class DependentData: def __init__(self, case_id): self.case_id = case_id self.operat_excel = OperationExcel() self.run_method = RunMethod() self.get_data = GetData() # 通关caseID来获取该caseID的整行数据 def get_case_line_data(self): rows_data = self.operat_excel.get_rows_data(self.case_id) return rows_data # 执行依赖测试。获取结果 def run_dependent(self): row = self.operat_excel.get_row_number(self.case_id) request_data = self.get_data.get_data_for_json(row) # header = self.get_data.is_header(row) url = self.get_data.get_request_url(row) method = self.get_data.get_request_method(row) res = self.run_method.run_main(method, url, request_data) return res.json() # 根据依赖的key去获取执行依赖测试case的相应,然后返回 def get_data_for_key(self, row): depend_data = self.get_data.get_depend_key(row) respense_data = self.run_dependent() json_exe = parse(depend_data) madle = json_exe.find(respense_data) data = [math.value for math in madle] if len(data) == 0: print('依赖数据异常') return None else: return data[0]
class RunTest(object): """这是RunTest""" def __init__(self): self.run_method = RunMethod() self.data = GetData() self.common_util = CommonUtil() self.send_email = SendMail() def go_on_run(self): pass_list = [] fail_list = [] rows_count = self.data.get_case_lines() for i in range(1, rows_count): res = None url = self.data.get_request_url(i) method = self.data.get_request_method(i) is_run = self.data.get_is_run(i) data = self.data.get_request_data_by_json(i) header = self.data.get_header(i) expect_result = self.data.get_expect_result(i) if is_run == "yes": res = self.run_method.run_main(method, url, data, header) if self.common_util.is_contain(expect_result, res): print("用例{}测试通过".format(i)) pass_list.append(i) self.data.write_actual_result(i, 'PASS') else: print("用例{}测试失败".format(i)) fail_list.append(i) self.data.write_actual_result(i, res) print(res) print("=============================") print("{}通过".format(len(pass_list))) print("{}失败".format(len(fail_list))) self.send_email.send_main(pass_list, fail_list)
def run_depnedent(self): run_method = RunMethod() row_num = self.operation.get_rows_num(self.case_id) # 获取行号 request_data = self.data.get_json_data(row_num) # 获取请求数据 method = self.data.get_request_method(row_num) # 获取请求方法 url = self.data.get_request_url(row_num) cookies = {"SESSION": "bdbd5d09-29c5-40f8-aa16-cae274c1c6cd"} cookie = self.data.get_cookies_value(row_num) if cookie == 'yes': get_cookie = OperationJson('../dataconfig/cookie.json') cooki = get_cookie.get_data('SESSION') cookies = {"SESSION": cooki} res = run_method.run_main(method, url, request_data, cookies) # 发送请求 else: res = run_method.run_main(method, url, request_data) return json.loads(res)
def run_dependent(self): run_method = RunMethod() row_num = self.oper_excel.get_row_num(self.case_id) print("row_num:", row_num) row_data = self.get_case_line_data() print("row_data:", row_data) request_data = self.data.get_data_for_json(row_num) print("request_data:", request_data) url = self.data.get_url(row_num) print("url:", url) method = self.data.get_request_type(row_num) print("method:", method) token_header = self.data.get_token_header(row_num, self.util.getToken(0)) print("依赖的token_header:", token_header) res = run_method.run_main(method, url, request_data, token_header) print("res:", res) return json.loads(res)
def run_depend_case(self): run_method = RunMethod() row_num = self.operation.get_row_num(self.casi_id) # 获取行号 request_data = self.data.get_json_data(row_num) # 获取请求数据 request_method = self.data.get_request_way(row_num) # 获取请求方法 url = self.data.get_url(row_num) cookie = self.data.get_is_cookies(row_num) if cookie == 'yes': operation = OperationJson('../data/scm-cookies.json') cookie = operation.get_data('SESSION') cookies = { "SESSION": cookie } res = run_method.run_main(request_method, url, request_data, cookie) else: res = run_method.run_main(request_method, url, request_data) return json.loads(res)
class RunTest(): def __init__(self): self.run_method = RunMethod() self.data = GetData() self.com_util = CommonUtil() self.depend_data = DependentData() # 程序执行 def go_on_run(self): res = None #获取case个数(获取有数据的单元格行) rows_count = self.data.get_case_lines() #循环判断要执行的case,跳过第一行标题开始循环 for i in range(1, rows_count): #获取是否执行 is_run = self.data.get_is_run(i) # print is_run # #判断is_run的值为true时执行 if is_run: # print i #获取url url = self.data.get_request_url(i) # print url #获取请求类型 method = self.data.get_request_method(i) # print method #获取数据 data = self.data.get_data_for_json(i) # print data expect = self.data.get_expect_data(i) #获取header(默认demo) # header = self.data.demo_header() #获取excel中指定header header = self.data.is_header(i) # print header #获取依赖数据 depend_case = self.data.is_depend(i) #判断是否需要依赖数据 if depend_case != None: #获取依赖的响应数据 depend_response_data = self.depend_data.get_data_for_key(i) #获取依赖key depend_key = self.data.get_depend_field(i) #将获取到的依赖case响应数据赋值给依赖key request_data[depend_key] = depend_response_data #获取响应数据 res = self.run_method.run_main(method, url, data, header) return res #打印结果并转码为字符串类型 # print res.text.encode('unicode-escape').decode('string_escape') #判断返回结果与预期结果比对 if self.com_util.is_contain(expect, res): self.data.write_result(i, 'pass') else: self.data.write_result(i, 'false')
class RunMain: #实例化一些基本的工具个data def __init__(self): self.opera_excel = OperationExcel() self.data = GetData() self.run_method = RunMethod() self.comm_util = CommUtil() self.send_mail = SendMail() #主函数运行入口 def go_on_run(self): pass_count = 0 fail_count = 0 #获取数据行数 rows_count = self.opera_excel.get_rows() #循环数据,并取值进行post或get请求,并获取结果 for i in range(1, rows_count): is_run = self.data.is_run(i) # print(expact_result) if is_run: url = self.data.request_url(i) request_data = self.data.get_method_data_depend(i) # print(request_data) cookies = self.data.get_cookies(i) request_way = self.data.get_method_way(i) case_depend = self.data.get_case_depend_data(i) # print(case_depend) expact_result = self.data.expact_result(i) request_data_depend = self.data.get_method_data(i) #查看是否有数据依赖 if case_depend != '': data_depend = DataDepend() response_depend = data_depend.get_depend_data( i, case_depend, 0) request_data[request_data_depend] = response_depend #判断是否需要写入或读取cookie if cookies == 'write': cookie_data = OperationCookie().get_cookie( request_way, url, request_data) OperationJson().write_json('../datas/cookie.json', cookie_data) elif cookies == 'yes': cookie_data = OperationJson().get_cookie_data( '../datas/cookies.json') res = self.run_method.run_main(request_way, url, request_data) result = self.comm_util.comm_util(str(res['code']), expact_result) if result: self.data.write_data(i, 'Pass') pass_count += 1 else: self.data.write_data(i, 'Fail') fail_count += 1 self.send_mail.send_main(pass_count, fail_count)
def run_dependent(self): """执行依赖测试,获取结果""" # 通过sheet页名称读取对应sheet页的数据 self.data.get_sheet_data(self.sheet_name) # 通过sheet_name和case_id获取行号 row_num = self.operation_excel.get_rowNum_by_sheetName_and_caseId( self.sheet_name, self.case_id) url = self.data.get_request_url(row_num) method = self.data.get_request_method(row_num) request_data = self.data.get_request_data(self.sheet_name, row_num) headers = self.data.get_is_header(row_num) cookies = self.data.get_is_cookie(row_num) run_method = RunMethod() res = run_method.run_method(method, url, request_data, headers, cookies) return json.loads(res)
class RunTest: def __init__(self, ): self.run_method = RunMethod() self.data = GetData() # 程序执行的 def go_on_run(self): rows_count = self.data.get_case_lines() res = None for i in range(1, rows_count): url = self.data.get_url(i) method = self.data.get_request_method(i) is_run = self.data.get_is_run(i) data = self.data.get_data_for_json(i) header = self.data.is_header(i) if is_run: res = self.run_method.run_main(method, url, data, header) print(res)
class RunTest: def __init__(self): self.run_method = RunMethod() self.data = GetData() self.com_util = CommonUtil() self.send_mail = SendEmail() def go_on_run(self): res = None pass_count = [] fail_count = [] rows_count = self.data.get_case_lines() print(rows_count) for i in range(1, rows_count): #获取excel表格中的数据 url = self.data.get_request_url(i) method = self.data.get_request_method(i) is_run = self.data.get_is_run(i) data = self.data.get_request_data(i) header = self.data.is_header(i) expect = self.data.get_expcet_data(i) print(url, method, is_run, data, header, expect) #判断是否执行 if is_run: res = self.run_method.run_main(method, url, data, header) info(res) #print(res) #判断预期结果和实际结果 if self.com_util.is_contain(expect, res['data']): #如果通过就把行号写入定义的列表中 pass_count.append(i) #在excel表中的实际结果中输入测试结果 self.data.write_result(i, "pass") print("测试通过") else: print("测试失败") #把执行失败的行号写入定义的列表中 fail_count.append(i) print(len(pass_count)) print(len(fail_count)) self.send_mail.send_main(pass_count, fail_count)
class Test(unittest.TestCase): def setUp(self): self.run = RunMethod() self.ExcelData = OperationExcel() self.JsonData = OperationJson() def tearDown(self): pass def test_01(self): url = self.ExcelData.get_cell_value(1, 2) print url data = self.JsonData.get_data(self.ExcelData.get_cell_value(1, 4)) print data res = self.run.run_main(url, 'POST', data) print res print '123'