def physical_pro_test(): a = f2.D() user_code = a.get_user_code() res_session = requests.session() photodata1 = f3.photo1() photodata2 = f3.photo2() while True: #无限循环 try: usercode = int(input('请输入用户id')) if (usercode, ) in user_code: usercode = str(usercode) data = {'userCode': usercode} user_info = res_session.post(url=f1.kkweight_app_url2 + f1.体侧用户信息, json=data) #print(user_info.json()) data = { 'report': { "frontUserPhotoInfo": { "photoMemo": "666", "photoData": photodata1, 'photoUrl': '' }, "physicalType": 0, "sideUserPhotoInfo": { "photoMemo": "666", "photoData": photodata2, 'photoUrl': '' }, "submitReport": 0, "userBaseInfo": { "age": 23, "armLeft": 33, "armRight": 33, "chestCircumference": 33, "gender": "男", "height": 174, "hipCircumference": 33, "legLeft": 33, "legRight": 33, "name": "小号", "personType": "普通人", "waistCircumference": 33 }, "userInjureInfo": { "userHurtInfoList": [], "userInjureHistoryList": [] }, "userWeightInfo": { "bmi": 21.1, "bmr": 1796.3, "bones": 2.8, "bonesRatio": 4.4, "entrailsFat": 5, "fat": 10, "fatRatio": 15.6, "muscle": 51.2, "muscleRatio": 80, "squatCount": 33, "water": 35.8, "waterRatio": 56, "weight": 64 } }, "userCode": 3008370 } data['userCode'] = usercode upload_data = res_session.post(url=f1.kkweight_app_url2 + f1.上传体侧数据接口, json=data) print(upload_data.json().get('reportUrl')) break else: print('查不到该用户') except ValueError: print('请输入整数')
import pad_app.主要接口.interface as f1 import 智运.login as f2 import pad_app.上课.function as f6 import 智运.kk_storefront_sql as f3 import 智运.student.yuqiresult as f5 import requests import smpt.youjian as f7 import time import assertpy.assertpy.assertpy as f4 uname = '13910211681' pwd = '123456' f = f6.D() #number=f.number() res_session = requests.session() login_log = f2.log(uname, pwd, res_session) headers = { 'user_Agent': 'KKCoach/Android', 'connection': 'Keep-Alive', 'Accept-Encoding': 'gzip', 'Host': 'test.kuaikuaikeji.com', 'Cache-Control': 'no-cache', } data = {"userUuid": "451ddfe4-b911-4105-b778-87552a6cb508"} url1 = f1.智运获取学员详细信息接口 ss = res_session.post(url=f1.kk_zhiyun_url3 + url1, json=data, headers=headers) #f4.assert_warn(ss.status_code).is_equal_to(200) f7.is_email(ss, url1, None) url1 = f1.智运跟进记录接口 ss1 = res_session.post(url=f1.kk_zhiyun_url3 + url1, json=data,
import pymysql import requests import re import time import uuid import pad_app.上课.function as ff a = ff.A(2) b = ff.D() def tel(): #tel=input('上课教练账号:') # tel='15828640467' #tel = '13691421359' tel = '17600958351' coachId = a.get_coachId(tel) return coachId #uuid=uuid.uuid1() def add_class(coachId): a.addclass(coachId) # print('添加成功') def add_class_private(coachId, user_uuid): a.addclass_private(coachId, user_uuid)
def report_test(data1): #print(data1) uname = '17600958351' pwd = '123456' res_session = requests.session() tme1 = time.time() tme2 = time.time() * 1000 #毫秒级时间戳 if log(uname, pwd, res_session).status_code == 200: data_ = data1.get('classDataList') coachId = log(uname, pwd, res_session).json()['coachId'] for y in data_: y = y coursecode = y.get('courseCode') classesid = y.get('classesId') # subjectid = y.get('subjectId') #print(data) n = int(len(data_)) print(coursecode) if 'SJ' not in coursecode: classes_id = ff2.add_class1(coachId, classesid, coursecode, n) #加的课的id,不可缺少 print('classid') print(classes_id) a = fff.A(2) gym_id = a.get_gymid(coachId) subjectid = a.get_subjectId(gym_id) #classesId = y.get('classesId') # 好简单 ,昨天试了半天。目前感觉还不是很好 #startTime = y.get('startTime') # 毫秒级时间戳 #endTime = y.get('endTime') #print(tme1) data = { 'coachId': coachId, 'listRange': 0, 'listSort': 0, 'pageIndex': 0, 'pageSize': 100 } headers = { 'user_Agent': 'KKTabletUDP/Android', 'connection': 'Keep - Alive', 'Accept - Encoding': 'gzip', 'Host': 'test.kuaikuaikeji.com', 'Cache - Control': 'no-cache' } r = res_session.post(url=f1.kkweight_app_url2 + f1.获取课程列表信息, json=data, headers=headers) data1 = { 'classesId': classes_id, } st = res_session.post(url=f1.kkweight_app_url2 + f1.开始课程, json=data1, headers=headers) #coursecode=st.json() data2 = { 'coachId ': coachId, 'classesId': classes_id, 'courseCode': coursecode } cek1 = res_session.post(url=f1.kkweight_app_url2 + f1.获取课程详细信息, json=data2, headers=headers) cek2 = res_session.post(url=f1.kkweight_app_url2 + f1.查看签到状态, json=data2, headers=headers) numbers = cek2.json().get('userCheckinMap') t = [] i1 = len(numbers) #classes_id=(classes_id) for y in numbers: # b=numbers[y] t.append(y) # 把人数换成列表格式 # print(t[0]) #data1 = f2.data1() #data1 = data1.get('classDataList') start_time1 = (time.time()) * 1000 #print(start_time1) #start_time = time.strftime("%Y-%m-%d %H:%M:%S", start_time1) # print(start_time) end_time1 = (time.time() + 3600) * 1000 #print(end_time1 ) #end_time = time.strftime("%Y-%m-%d %H:%M:%S", end_time1) #print(len(data1)) classDataList = [] #print(1) #print(n) for i in range(n): # print(data_) # classesId = '218527' #weight=data_[i]['weightData'] #print(weight) #print(i) if 'weightData' in data_[i]: data_[i]['weightData'] = data_[i]['weightData'] data_[i]['baseData'] = data_[i]['baseData'] else: pass data_[i]['endTime'] = end_time1 data_[i]['startTime'] = start_time1 #data1[i]['subjectId'] = subjectid data_[i]['userUuid'] = t[i] data_[i]['classesId'] = classes_id data_[i]['subjectId'] = subjectid #data1[i]['courseCode'] = coursecode classDataList.append(data_[i]) #print(3) # print(classDataList) # cek3 = res_session.post(url='http://test.kuaikuaikeji.com/kcas/PadGetCoachClassInfoV2', json=data,headers=headers) # 刷新后的页面,获取课程详情 #print(2) data3 = { 'classDataList': classDataList, "uploadType": 1, 'uploadVersion': 3 } #print(coursecode ) report1 = res_session.post(url=f1.kkweight_app_url2 + f1.上传报告, json=data3, headers=headers) # print(report1.json()) # print(report1.status_code) #print(classesId) aa = fff.D() number = aa.number() #tmeout = (report1.elapsed.microseconds)/number#发送请求到服务器端响应的时间大于1秒,只会截取后面的小数部分 tmeout1 = report1.elapsed.total_seconds( ) #这个才是正确的 获取响应时间,发送请求到收到相应的时间差 #report1.elapsed. print('上传报告所需时间', tmeout1) #print('上传报告所需时间', tmeout) if report1.status_code == 200: data4 = {'classesId': classes_id, 'subjectId': subjectid} getreport1 = res_session.post(url=f1.kkweight_app_url2 + f1.报告列表, json=data4, headers=headers) # print(getreport1.json()) classReportList = getreport1.json().get('classReportList') for x in range(len(classReportList)): cl = classReportList[x] reurl = cl.get('reportUrl') print(reurl) #if getreport1.status_code!=200: #print(classes_id) #exit() #else: # print('success') #classReportList = getreport1.json().get('classReportList') print(classes_id) else: print('上传失败 ', report1.status_code) else: pass else: print('用户名或密码错误')
async def hello(self, datas): async with aiohttp.ClientSession() as session: headers = { 'user_Agent': 'KKTabletUDP/Android', 'connection': 'Keep - Alive', 'Accept - Encoding': 'gzip', 'Host': 'test.kuaikuaikeji.com', 'Cache - Control': 'no-cache', } username = '******' password = '******' async with session.post( "http://test.kuaikuaikeji.com/kcas/PadCoachLoginV2", headers=headers) as res: auth = res.headers.get('WWW-Authenticate', '') m = hashlib.md5() # 创建md5对象 m1 = hashlib.md5() # m2=hashlib.md5() # password='******' # username='******' '''strs1=(username+password).encode('utf-8') m.update(strs1)#生成加密串 ha=m.hexdigest()#获取加密串 #print(ha)''' m.update(password.encode('utf-8')) pd = m.hexdigest() password1 = base64.encodebytes( pd.encode('utf-8'))[:-1] # base64编码 password1 = password1.decode('utf-8') # password2=password1.decode('utf-8') # print(password1) '''username1=username.encode('utf-8')#string类型转换成byte类型 up=(username1+password1).encode('utf-8') print(up)#也可以用''' up = (username + password1) strs2 = (auth + up).encode('utf-8') m1.update(strs2) # 生成加密串 resp = m1.hexdigest() # 获取加密串` response = base64.encodebytes(resp.encode('utf-8'))[:-1] response = response.decode('utf-8') # byte类型转换成string类型 author = "user=\"" + username + "\",response=\"" + response + "\"" print(author) headers = { 'user_Agent': 'KKTabletUDP/Android', 'connection': 'Keep - Alive', 'Accept - Encoding': 'gzip', 'Host': 'test.kuaikuaikeji.com', 'Cache - Control': 'no-cache', 'authorization': author, } async with session.post( "http://test.kuaikuaikeji.com/kcas/PadCoachLoginV2", headers=headers) as req: a = await req.json() if req.status == 200: data_ = datas.get('classDataList') coachId = a['coachId'] for y in data_: y = y coursecode = y.get('courseCode') classesid = y.get('classesId') # subjectid = y.get('subjectId') # print(data) n = int(len(data_)) print(coursecode) if 'SJ' not in coursecode: classes_id = ff2.add_class1( coachId, classesid, coursecode, n) # 加的课的id,不可缺少 print('classid') print(classes_id) a = fff.A(2) gym_id = a.get_gymid(coachId) subjectid = a.get_subjectId(gym_id) # classesId = y.get('classesId') # 好简单 ,昨天试了半天。目前感觉还不是很好 # startTime = y.get('startTime') # 毫秒级时间戳 # endTime = y.get('endTime') # print(tme1) data = { 'coachId': coachId, 'listRange': 0, 'listSort': 0, 'pageIndex': 0, 'pageSize': 100 } headers = { 'user_Agent': 'KKTabletUDP/Android', 'connection': 'Keep - Alive', 'Accept - Encoding': 'gzip', 'Host': 'test.kuaikuaikeji.com', 'Cache - Control': 'no-cache' } # r = res_session.post(url=f1.kkweight_app_url2 + f1.获取课程列表信息, json=data, headers=headers) # data1 = { # 'classesId': classes_id, # } # st = res_session.post(url=f1.kkweight_app_url2 + f1.开始课程, json=data1, headers=headers) # coursecode=st.json() data2 = { 'coachId ': coachId, 'classesId': classes_id, 'courseCode': coursecode } # cek1 = res_session.post(url=f1.kkweight_app_url2 + f1.获取课程详细信息, json=data2, headers=headers) async with session.post(url=f1.kkweight_app_url2 + f1.查看签到状态, json=data2, headers=headers) as req1: numbers1 = await req1.json() print(numbers1) numbers = numbers1['userCheckinMap'] t = [] i1 = len(numbers) # classes_id=(classes_id) for y in numbers: # b=numbers[y] t.append(y) # 把人数换成列表格式 # print(t[0]) # data1 = f2.data1() # data1 = data1.get('classDataList') start_time1 = (time.time()) * 1000 # print(start_time1) # start_time = time.strftime("%Y-%m-%d %H:%M:%S", start_time1) # print(start_time) end_time1 = (time.time() + 3600) * 1000 # print(end_time1 ) # end_time = time.strftime("%Y-%m-%d %H:%M:%S", end_time1) # print(len(data1)) classDataList = [] # print(1) # print(n) for i in range(n): # print(data_) # classesId = '218527' # weight=data_[i]['weightData'] # print(weight) # print(i) if 'weightData' in data_[i]: data_[i]['weightData'] = data_[i][ 'weightData'] data_[i]['baseData'] = data_[i][ 'baseData'] else: pass data_[i]['endTime'] = end_time1 data_[i]['startTime'] = start_time1 # data1[i]['subjectId'] = subjectid data_[i]['userUuid'] = t[i] data_[i]['classesId'] = classes_id data_[i]['subjectId'] = subjectid # data1[i]['courseCode'] = coursecode classDataList.append(data_[i]) # print(3) # print(classDataList) # cek3 = res_session.post(url='http://test.kuaikuaikeji.com/kcas/PadGetCoachClassInfoV2', json=data,headers=headers) # 刷新后的页面,获取课程详情 # print(2) data3 = { 'classDataList': classDataList, "uploadType": 1, 'uploadVersion': 3 } # print(coursecode ) time1 = time.time() async with session.post( url=f1.kkweight_app_url2 + f1.上传报告, json=data3, headers=headers) as req2: # print(report1.json()) # print(report1.status_code) # print(classesId) aa = fff.D() number = aa.number() # await req2.json() time2 = time.time() # tmeout = (report1.elapsed.microseconds)/number#发送请求到服务器端响应的时间大于1秒,只会截取后面的小数部分 # tmeout1 = req2.elapsed.total_seconds() # 这个才是正确的 获取响应时间,发送请求到收到相应的时间差 # report1.elapsed. print('上传报告所需时间', time2 - time1) # print('上传报告所需时间', tmeout) if req2.status == 200: data4 = { 'classesId': classes_id, 'subjectId': subjectid } async with session.post( url=f1.kkweight_app_url2 + f1.报告列表, json=data4, headers=headers) as req4: # print(getreport1.json()) classReportList1 = await req4.json( ) classReportList = classReportList1[ 'classReportList'] for x in range( len(classReportList)): cl = classReportList[x] reurl = cl.get('reportUrl') print(reurl) # if getreport1.status_code!=200: # print(classes_id) # exit() # else: # print('success') # classReportList = getreport1.json().get('classReportList') print(classes_id) else: print('上传失败 ', req2.status) else: pass else: print('用户名或密码错误')
import sys sys.path.append('..') import pad_app.主要接口.interface as f1 import requests import pad_app.上课.function as f2 import pad_app.体测.photo as f3 import pad_app.体测.coursecode as f4 a = f2.D() user_code = a.get_user_code() res_session = requests.session() photodata1 = f3.photo1() photodata2 = f3.photo2() courseCodeName = f4.型男减脂型例子 courseCodeType = f4.型男减脂code while True: # 无限循环 gender = input('请输入男或者女') if gender == '男' or gender == '女': try: usercode = int(input('请输入用户id')) if (usercode, ) in user_code: usercode = str(usercode) data = {'userCode': usercode} user_info = res_session.post(url=f1.kkweight_app_url2 + f1.体侧用户信息, json=data) print(user_info.json()) name = user_info.json().get('userName')
headers = { 'Cache-Control': 'no-cache', 'User-Agent': 'KKUSER-4.4.1-test-19727/Android/4.4.4/vivo/vivo X5F', 'Content-Type': 'application/x-www-form-urlencoded', # 'Content-Length': 84, 'Host': 'ts.kuaikuaikeji.com', # 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip' } city = '上海' name = '石燕国' user_code = 3013375 user_coupon_uuid = f3.D().coupon_user('8dcd76a8-917d-11e8-bf15-448a5bad1c04', 'bd02b354-2355-3251-a066-e64e05ce93b6') print(user_coupon_uuid) data1 = ( 'tele=15234171516&private_flag=2&ele_agreement_flag=1&pay_type=1&real_name={name}&user_code={user_code}&card_face_value=720000&order_subject_number=1&user_coupon_uuid={user_coupon_uuid}&price_code=private&coins_pay=0&order_type=0&city={city}' .format(name=parse.quote(name), user_code=user_code, user_coupon_uuid=user_coupon_uuid, city=parse.quote(city))) #data1=('tele=17600958351&ele_agreement_flag=1&pay_type=1&real_name=%E5%BF%AB%E5%BF%AB&user_code=3008370&gym_id=2648597473593346&coins_pay_count=362800&order_subject_number=1&price_code=3showyao36_60&coins_pay=1&order_type=0&city=%E5%8C%97%E4%BA%AC') r = resssion.post(url=f2.kk_user_app_url3 + f2.购买课程, headers=headers, data=data1) print(r.status_code) order_uuid = r.json()['order_uuid'] r = resssion.get(url=f2.kk_user_app_url3 + f2.购课成功2(order_uuid),