40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import json
|
|||
|
|
import re
|
||
|
|
from urllib.parse import urlparse
|
||
|
|
|
||
|
|
with open("/home/creserver/Desktop/Vaishno_workspace/Jsons/credentials_23-10-2026.json") as f:
|
||
|
|
creds = json.load(f)
|
||
|
|
|
||
|
|
with open("web/docs/index.html") as f:
|
||
|
|
html = f.read()
|
||
|
|
|
||
|
|
m = re.search(r'<script id="api-data" type="application/json">(.*?)</script>', html, re.DOTALL)
|
||
|
|
data = json.loads(m.group(1))
|
||
|
|
|
||
|
|
cred_apis = creds["data"]
|
||
|
|
all_eps = [ep for s in data["sections"] for ep in s["eps"]]
|
||
|
|
print(f"Creds entries: {len(cred_apis)}")
|
||
|
|
print(f"Doc endpoints: {len(all_eps)}")
|
||
|
|
|
||
|
|
for c in cred_apis:
|
||
|
|
k = c["api_key"]
|
||
|
|
url = c["api_ip_link"]
|
||
|
|
parsed = urlparse(url)
|
||
|
|
path = parsed.path.rstrip("/")
|
||
|
|
# e.g. path is /apis/mlm/teeth_whitener
|
||
|
|
# Find matching endpoints
|
||
|
|
# Check if any segment of path matches ep path
|
||
|
|
segments = [s for s in path.split("/") if s and s not in ("apis", "mlm", "lxds", "flxf", "flxk", "cmf", "sdxl", "flux", "flux_fill")]
|
||
|
|
matches = []
|
||
|
|
for ep in all_eps:
|
||
|
|
ep_p = ep["path"]
|
||
|
|
for seg in segments:
|
||
|
|
if seg in ep_p:
|
||
|
|
matches.append(ep)
|
||
|
|
break
|
||
|
|
print(f"\nAPI KEY: {k}")
|
||
|
|
print(f" URL: {url}")
|
||
|
|
print(f" Matches ({len(matches)}):")
|
||
|
|
for me in matches:
|
||
|
|
print(f" - {me['method']} {me['path']} | Title: {me['title']}")
|