forked from 24F5/sport
上传文件至 /
添加了对openid有效性的判断以及用户手动确认是否继续运行
This commit is contained in:
parent
391e7930ec
commit
35bed08613
31
main.py
31
main.py
@ -1,3 +1,5 @@
|
||||
from distutils.command.check import check
|
||||
from symbol import continue_stmt
|
||||
from time import sleep
|
||||
|
||||
import requests
|
||||
@ -17,7 +19,12 @@ headers = {
|
||||
|
||||
def login(openid, phone_type="PJF110_Android%2015"):
|
||||
url = f"https://sport.cqupt.edu.cn/wxapp/wxUnifyId/checkBinding?wxCode=&openid={openid}&phoneType={phone_type}"
|
||||
response = requests.get(url, headers=headers).json()
|
||||
response = requests.get(url, headers=headers,verify=False).json()
|
||||
print(response)
|
||||
if response['data']['isBind']=='true' :
|
||||
print("成功获取数据")
|
||||
else:
|
||||
raise ValueError("openid错误")
|
||||
print(f"正在登入, MSG: {response['msg']}, CODE: {response['code']}")
|
||||
print(f"Token: {response['data']['token']}")
|
||||
headers['token'] = response['data']['token']
|
||||
@ -25,9 +32,21 @@ def login(openid, phone_type="PJF110_Android%2015"):
|
||||
|
||||
def get_user():
|
||||
url = f"https://sport.cqupt.edu.cn/wxapp/wxUnifyId/getUser"
|
||||
response = requests.get(url, headers=headers).json()
|
||||
response = requests.get(url, headers=headers,verify=False).json()
|
||||
print(f"获取用户信息, MSG: {response['msg']}, CODE: {response['code']}")
|
||||
print(f"姓名: {response['data']['username']}, 学号: {response['data']['studentNo']}")
|
||||
while True:
|
||||
print(f"是否继续进行跑步打卡(Y/N)")
|
||||
user_input=input()
|
||||
if user_input == "Y" or user_input == "y":
|
||||
break
|
||||
elif user_input == "N" or user_input == "n":
|
||||
print("bye")
|
||||
exit()
|
||||
else:
|
||||
print("输入无效")
|
||||
|
||||
|
||||
|
||||
def start(place_name="太极运动场",place_code="T1005"):
|
||||
url = f"https://sport.cqupt.edu.cn/wxapp/sportRecord/sport/start2"
|
||||
@ -35,13 +54,13 @@ def start(place_name="太极运动场",place_code="T1005"):
|
||||
"placeName": place_name,
|
||||
"placeCode": place_code
|
||||
}
|
||||
response = requests.post(url, headers=headers,json=data).json()
|
||||
response = requests.post(url, headers=headers,json=data,verify=False).json()
|
||||
print(f"开始打卡, MSG: {response['msg']}, CODE: {response['code']}, DATA: {response['data']}")
|
||||
return response['data']
|
||||
|
||||
def sport_record(record_no):
|
||||
url = f"https://sport.cqupt.edu.cn/wxapp/sportRecord/info/{record_no}"
|
||||
response = requests.get(url, headers=headers).json()
|
||||
response = requests.get(url, headers=headers,verify=False).json()
|
||||
print(f"获取打卡信息, MSG: {response['msg']}, CODE: {response['code']}")
|
||||
print(f"打卡信息: {response['data']['studentName']}, 公里: {response['data']['mileage']}")
|
||||
|
||||
@ -51,7 +70,7 @@ def post_record_data(record_no,pointlist):
|
||||
"sportRecordNo": record_no,
|
||||
"sportPointList": pointlist
|
||||
}
|
||||
response = requests.post(url, headers=headers,json=data).json()
|
||||
response = requests.post(url, headers=headers,json=data,verify=False).json()
|
||||
print(f"提交打卡信息, MSG: {response['msg']}, CODE: {response['code']}, 路程: {response['data']['mileage']}, 时间: {response['data']['timeConsuming']}")
|
||||
if response['code'] == '10200':
|
||||
return 0
|
||||
@ -66,7 +85,7 @@ def get_point_from_file():
|
||||
def end(record_no):
|
||||
url = f"https://sport.cqupt.edu.cn/wxapp/sportRecord/sport/end/{record_no}"
|
||||
data = {}
|
||||
response = requests.post(url, headers=headers,json=data).json()
|
||||
response = requests.post(url, headers=headers,json=data,verify=False).json()
|
||||
print(f"结束打卡, MSG: {response['msg']}, CODE: {response['code']}")
|
||||
|
||||
def main():
|
||||
|
Loading…
x
Reference in New Issue
Block a user