#!/opt/pw/bin/python """newlink.py OUTPREFIX — open the household's OLD (spent) bind link and press „Új linket kérek" (B7). Env BIND_TOKEN. Screenshots before and after; prints the visible page text. The token is never printed (the URL is masked).""" import os, re, sys from playwright.sync_api import sync_playwright out = sys.argv[1] with sync_playwright() as p: b = p.chromium.launch(executable_path="/usr/bin/chromium", args=["--no-sandbox"]) ctx = b.new_context(locale="hu-HU", extra_http_headers={"Accept-Language": "hu-HU"}, timezone_id="Europe/Budapest", viewport={"width": 390, "height": 844}, device_scale_factor=2, is_mobile=True, has_touch=True) pg = ctx.new_page() r = pg.goto("https://hub.felhom.eu/bind/" + os.environ["BIND_TOKEN"], wait_until="networkidle") print("open", r.status if r else "-", re.sub(r"\s+", " ", pg.inner_text("body"))[:500]) pg.screenshot(path=f"{out}-1-old-link-phone-hu.png", full_page=True) btn = pg.get_by_text("Új linket kérek", exact=False) if btn.count(): btn.first.click(); pg.wait_for_load_state("networkidle") print("after press:", re.sub(r"\s+", " ", pg.inner_text("body"))[:700]) pg.screenshot(path=f"{out}-2-after-press-phone-hu.png", full_page=True) else: print("no „Új linket kérek” button on the page") b.close()