This repository was archived by the owner on Nov 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
133 lines (126 loc) · 4.57 KB
/
Copy pathrun.py
File metadata and controls
133 lines (126 loc) · 4.57 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import requests
import json
from config import *
from time import *
import wxpusher
import hashlib
import random
import amap
def getrunningrule():
r = requests.get(config_url['home_page'],headers=config_header_get)
json_r = json.loads(r.text)
return json_r['data']['runningRule']
def start():
data = {
"campusId": 22,
"latitude": config_start_latitude + (random.randint(-20000000000, 200000000000) / 10000000000000000),
"longitude": config_start_longitude + (random.randint(-20000000000, 200000000000) / 10000000000000000),
"type": 1,
}
r = requests.post(config_url['run_start'], headers=config_header_post, data=json.dumps(data))
return r.text
def end(start_text, yesterday=False):
start_s = json.loads(start_text)
circuitString = {
"randomCircuit": {
"length": start_s['data']['randomCircuit']['length'],
"ordered": start_s['data']['randomCircuit']['ordered'],
"requireLatitude": start_s['data']['randomCircuit']['requireLatitude'],
"requireLongitude": start_s['data']['randomCircuit']['requireLongitude'],
},
"runningRule": getrunningrule(),
"time": start_s['data']['time'],
}
latitude = []
longitude = []
speed = []
road = amap.getrouad(start_text)
d_list = road.split(';')
formatList = list(set(d_list))
formatList.sort(key=d_list.index)
d_num = len(formatList) - 1
s_num = 0
for i in range(0,d_num):
if formatList[i] == '':
continue
f = formatList[i].split(',')
t_a = float(f[1])
t_b = float(f[0])
if formatList[i-1] == '':
continue
f = formatList[i-1].split(',')
t_c = float(f[1])
t_d = float(f[0])
for j in range(0,10):
t_l = ((t_a - t_c) / 10) * j + t_c + (random.randint(-20000000000, 20000000000) / 10000000000000000)
t_r = ((t_b - t_d) / 10) * j + t_d + (random.randint(-20000000000, 20000000000) / 10000000000000000)
latitude.append(t_l)
longitude.append(t_r)
s_num = s_num + 1
for i in range(0,s_num):
tmp = random.randint(100,200)
speed.append(tmp)
timestamp = int(round(time() * 1000))
if yesterday:
timestamp -= 86400000
passTime = [
random.randint(timestamp - 500000, timestamp),
random.randint(timestamp - 500000, timestamp),
random.randint(timestamp - 500000, timestamp)
]
distance = random.randint(3100, 3300)
totalTime = random.randint(700, 750)
startTime = timestamp - 700000
endTime = timestamp
phone = config_Phone
s_md5 = "EndRunningInfo{{a='{}', b={}, c={}, d={}, e={}, f={}, g='{}'}}".format("", str(totalTime), str(distance),
"1", str(startTime), str(endTime),
str(phone))
hl = hashlib.md5()
hl.update(s_md5.encode("utf-8"))
md5 = hl.hexdigest()
data = {
"calories": random.randint(200, 330),
"circuitInfo": {
"circuitString": json.dumps(circuitString),
"latitude": [
latitude,
],
"longitude": [
longitude,
],
"passTime": passTime,
"randomLatitude": start_s['data']['randomCircuit']['requireLatitude'],
"randomLongitude": start_s['data']['randomCircuit']['requireLongitude'],
"segment": [
[
random.randint(timestamp - 650000, timestamp - 610000),
random.randint(timestamp - 1000, timestamp),
],
],
"speed": speed,
},
"distance": distance,
"endTime": endTime,
"id": 1,
"md5": md5,
"phone": phone,
"platform": 1,
"startTime": startTime,
"stepRate": random.randint(90, 120),
"totalTime": totalTime,
"type": 1,
"valid": 1,
"validDistance": distance,
"version": "V 2.4.4",
}
#print(json.dumps(data))
r = requests.post(config_url['run_end'], headers=config_header_post, data=json.dumps(data))
json_r = json.loads(r.text)
#print(r.text)
if json_r['data']['valid'] == 1:
print('跑步完成!')
wxpusher.send('您的跑步已经完成并成功提交')
else:
print('跑步失败!原因:'+json_r['data']['invalidReason'])
wxpusher.send('跑步失败!原因:'+json_r['data']['invalidReason'])