-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit.py
34 lines (23 loc) · 873 Bytes
/
submit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
import json
import datetime
from access_token import find_access_token
submit_url = 'http://dailyhealth-api.sustech.edu.cn/api/form/save'
content_path = './content.json'
header_path = './header.json'
def submit(token=''):
today = datetime.datetime.today()
date_string = "%d-%02d-%02d" % (today.year, today.month, today.day)
with open(content_path, encoding='utf-8') as f:
content = json.load(f)
with open(header_path, encoding='utf-8') as f:
header = json.load(f)
content['formDate'] = date_string
header['accessToken'] = token
response = requests.post(submit_url, data=json.dumps(content), headers=header)
print(response.status_code)
print(response.text)
if __name__ == "__main__":
token = find_access_token()
print(token)
submit(token)