Files
python----/智慧校园/公交车测试 copy.ipynb
T
2025-10-20 12:32:18 +08:00

5.0 KiB

In [1]:
import requests
import time
import random
import datetime
In [7]:
ip = "http://139.159.182.121:8090"
# param = {
#     "username": "zhongwei",
#     "password": "123456a",
#     "client_id": "client",
#     "grant_type": "password",
#     "client_secret": "123456",
# }
# data = requests.get(url=f"{ip}/oauth/token", params=param).json()
# token = data["access_token"]
# header = {
#     "content-type": "application/json",
#     "authorization": f"Bearer {token}",
# }
In [3]:
bandNos = ['0985704955','0890497621','2631768263']
In [ ]:
int(datetime.datetime.now().timestamp()*1000)
In [3]:
datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
Out [3]:
'2024-10-22 17:38:19'
In [5]:
datetime.datetime.strptime('2024-10-22 07:38:19', '%Y-%m-%d %H:%M:%S').timestamp()*1000
Out [5]:
1729553899000.0
In [8]:
requests.get(url=f"{ip}/schoolBus/crad",params={"bandNo": '0976835307',"serialNo":'865860043867069',"time":1729553899000}).text
Out [8]:
''
In [ ]:
103, 30
In [1]:
from geopy.distance import geodesic
# 定义两个地点的经纬度坐标
location1 = (30.70125, 103.99548 )#起点
location2 = (30.70423, 103.98864)#黄
location3 = (30.70260, 103.99447)#泡
# 计算地理距离
distance = geodesic(location1, location2).m
distance2 = geodesic(location2, location3).m
# 输出地理距离
print(f"{int(distance)}")
print(f"{int(distance2)}")
733 米
587 米
In [ ]:
for index,pos in enumerate(positions):
    x,y=pos
    response = requests.get(url=f"{ip}/schoolBus/gps",params={"serialNo":'868626047777357',"time":int(datetime.datetime.now().timestamp()*1000),"coodx":x,"coody":y}).text
    print(response)
    time.sleep(10)
In [ ]:
while True:
    data = requests.get(url=f"{ip}/schoolBus/location",params={"serialNo":'865860043833053'}).text
    print(data)
    time.sleep(30)
In [ ]:
requests.get(url=f"{ip}/schoolBus/crad",params={"bandNo": bandNos[0],"serialNo":'868626047775245',"time":int(datetime.datetime.now().timestamp()*1000)}).text
In [ ]:
response = requests.get(url=f"{ip}/schoolBus/gps",params={"serialNo":'868626047775245',"time":int(datetime.datetime.now().timestamp()*1000),"coodx":10399440, "coody":3070043}).text
print(response)