43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
# save_patient_detail_page.py
|
|
from pathlib import Path
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
STATE_FILE = r"/medevio_storage.json"
|
|
BASE_URL = "https://my.medevio.cz/mudr-buzalkova/klinika/pacienti"
|
|
PATIENT_ID = "fcb2414b-067b-4ca2-91b2-6c36a86d4cbb" # <-- any valid patient UUID
|
|
|
|
def main():
|
|
out_dir = Path(f"capture_patient_{PATIENT_ID}")
|
|
out_dir.mkdir(exist_ok=True)
|
|
|
|
html_path = out_dir / "detail.html"
|
|
screenshot_path = out_dir / "detail.png"
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True) # set False if you want to watch
|
|
context = browser.new_context(storage_state=STATE_FILE)
|
|
page = context.new_page()
|
|
|
|
# Open the detail directly
|
|
target_url = f"{BASE_URL}?pacient={PATIENT_ID}"
|
|
page.goto(target_url, wait_until="domcontentloaded")
|
|
|
|
# Wait a bit for the detail drawer/dialog to render
|
|
try:
|
|
page.wait_for_selector("[role='dialog'], div.MuiDrawer-paper, div[aria-modal='true']", timeout=10000)
|
|
except:
|
|
print("Warning: did not detect a detail panel quickly")
|
|
|
|
# Save raw HTML and screenshot
|
|
html_path.write_text(page.content(), encoding="utf-8")
|
|
page.screenshot(path=str(screenshot_path), full_page=True)
|
|
|
|
browser.close()
|
|
|
|
print("Saved:")
|
|
print(" -", html_path.resolve())
|
|
print(" -", screenshot_path.resolve())
|
|
|
|
if __name__ == "__main__":
|
|
main()
|