def my_re(cls, datas): hm = HandleMysql() phone = hm.get_non_existent() if re.search(r'{no_exist_phone}', datas): result = re.sub(r'{no_exist_phone}', phone, datas) return result return datas
def get_phone(cls, username, password='******', type=1): hr = HandleRequest() hm = HandleMysql() base_url = hy.read_yaml('api', 'load') register_url = hy.read_yaml('api', 'register') all_url = ''.join((base_url, register_url)) while True: phone = hm.get_non_existent() data = { "mobile_phone": phone, "pwd": password, "type": type, "reg_name": username } hr.common_head(hy.read_yaml('api', 'header')) result = hr.send(url=all_url, data=data) if result.json()['code'] == 0 and result.json()['msg'] == 'OK': break user_id = hm.get_mysql_result(sql=hy.read_yaml('mysql', 'user_id'), args=phone) result_data = { username: { "mobilephone": phone, "pwd": password, "user_id": user_id[0]['id'], "reg_name": username } } hr.close() hm.close() return result_data