Dish_Recognition/tools/_tmp_probe.py

29 lines
821 B
Python

import requests, re, json
js = requests.get("https://cpsb.ruimeida.cc/assets/index-Cxl1XTjI.js", timeout=30).text
# find public API or device status related
for n in [
"/api/public",
"public/",
"device",
"heartbeat",
"status",
"meal-schedules",
"recognize",
"X-API-Key",
"apiKey",
"deviceCode",
"device_code",
"online",
]:
c = js.count(n)
print(f"{n!r}: {c}")
# extract paths containing public
paths = sorted(set(re.findall(r'["\`]/api/public/[a-zA-Z0-9_/\-]+)', js)))
print("public paths", paths)
# extract strings with device
for m in re.finditer(r'.{0,40}device.{0,60}', js, flags=re.I):
s = m.group(0)
if any(k in s.lower() for k in ("api", "fetch", "post", "patch", "put", "status", "heart", "online", "code")):
print("DEV", repr(s)[:180])