You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB

from datetime import date, timedelta
from pathlib import Path
from curl_cffi import requests
# from tqdm import tqdm
start_date = date(2024, 1, 1)
end_date = date(2025, 1, 1)
delta = end_date - start_date
dates = [str(start_date + timedelta(days=i)) for i in range(delta.days)]
z = 8
xs = [153, 154, 155, 156]
ys = [79, 80]
hours = range(24)
vars = [
{"z": z, "x": x, "y": y, "hour": hour, "date": date}
for date in dates
for hour in hours
for x in xs
for y in ys
]
print(len(vars))
Path("./tiles").mkdir(parents=True, exist_ok=True)
def write_tiles(v):
date = v["date"]
hour = v["hour"]
z = v["z"]
x = v["x"]
y = v["y"]
url = f"https://prodvizhenie.mos.ru/tiles/v1/taxi/ride-start/{z}/{x}/{y}.pbf?hours={hour},{hour}&weekdays=1,2,3,4,5,6,7&dates={date},{date}&aggregation=h3"
r = requests.get(url, impersonate="chrome")
with open(Path(f"./tiles/{date}_{hour}_{z}_{x}_{y}.pbf"), "wb") as f:
f.write(r.content)
[write_tiles(v) for v in vars]