Files
weval-l99/pw-wtp-v20.py
2026-04-24 04:38:58 +02:00

33 lines
1.3 KiB
Python

#!/usr/bin/env python3
import json, sys, os, datetime
try:
from playwright.sync_api import sync_playwright
except ImportError:
print(json.dumps({"status":"no_playwright"}))
sys.exit(0)
TS = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
OUT = "/opt/weval-l99/pw-wtp-v20"
os.makedirs(OUT, exist_ok=True)
with sync_playwright() as p:
br = p.chromium.launch(headless=True, args=['--no-sandbox'])
ctx = br.new_context(ignore_https_errors=True, viewport={'width':1440,'height':900})
pg = ctx.new_page()
pg.goto("https://weval-consulting.com/weval-technology-platform.html", timeout=20000, wait_until='domcontentloaded')
pg.wait_for_timeout(3000)
# Scroll to the section
try:
sec = pg.query_selector('#wtp-session-v20-incident')
if sec:
sec.scroll_into_view_if_needed(timeout=5000)
pg.wait_for_timeout(2000)
shot = f"{OUT}/wtp-section-v20-{TS}.png"
sec.screenshot(path=shot)
print(json.dumps({"status":"CAPTURED","screenshot":shot,"section":"present"}))
else:
shot = f"{OUT}/wtp-missing-v20-{TS}.png"
pg.screenshot(path=shot, full_page=True)
print(json.dumps({"status":"SECTION_NOT_FOUND","screenshot":shot}))
except Exception as e:
print(json.dumps({"status":"error","err":str(e)[:200]}))
br.close()