Explorer
/proc/234/root/tmp/aa023_panel.py
← Zurück ↓ Download
import json
from pathlib import Path
from playwright.sync_api import sync_playwright
out=[]
with sync_playwright() as p:
 b=p.chromium.launch(headless=True); page=b.new_page(viewport={'width':1440,'height':1000})
 page.goto('https://sma.agentsolutions-mallorca.com/cockpit?days=14&sort=relevance&tab=radar',wait_until='networkidle')
 btn=page.locator('#blocked-filter-btn')
 if btn.is_visible(): btn.click()
 for h in page.locator('.cat-hdr').all():
  try:
   if not h.locator('xpath=following-sibling::*[1]').is_visible(): h.click()
  except: pass
 cards=page.locator('.sig:visible')
 for i in range(min(cards.count(),20)):
  c=cards.nth(i); sid=c.get_attribute('id'); title=c.locator('.sig-title').inner_text() if c.locator('.sig-title').count() else ''
  c.locator('.thumb').click(force=True); page.wait_for_timeout(20)
  panel=page.locator('#pcontent').inner_text() if page.locator('#pcontent').count() else ''
  out.append({'sid':sid,'title':title,'panel_has_title': bool(title and title[:30] in panel),'panel_len':len(panel)})
 page.screenshot(path='/home/hermes/Antworten/AA-023-detailpanel.png',full_page=True)
 b.close()
Path('/home/hermes/Antworten/AA-023-detailpanel.json').write_text(json.dumps(out,ensure_ascii=False,indent=2))
print(json.dumps({'tested':len(out),'passed':sum(x['panel_has_title'] for x in out),'failed':sum(not x['panel_has_title'] for x in out)}))