40 lines
No EOL
1.9 KiB
Python
40 lines
No EOL
1.9 KiB
Python
import asyncio, json
|
|
from playwright.async_api import async_playwright
|
|
|
|
async def main():
|
|
async with async_playwright() as p:
|
|
b = await p.chromium.launch(args=["--no-sandbox"])
|
|
pg = await b.new_page(viewport={"width": 1500, "height": 1000})
|
|
errs = []
|
|
pg.on("pageerror", lambda e: errs.append(f"PAGEERR {e}"))
|
|
pg.on("console", lambda m: errs.append(f"CONSOLE {m.text}") if m.type == "error" else None)
|
|
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
|
|
await pg.wait_for_timeout(2500)
|
|
await pg.click('#tabs button[data-view="calendar"]')
|
|
await pg.wait_for_timeout(3000)
|
|
|
|
info = await pg.evaluate("""() => {
|
|
const v = document.getElementById('view-calendar');
|
|
const out = {
|
|
header: v.querySelector('.card-title, h2, .sec-title')?.innerText.trim(),
|
|
meta: v.querySelector('.card-sub, .hint-txt')?.innerText.trim(),
|
|
dayCells: v.querySelectorAll('[data-day], .cal-cell, .day-cell').length,
|
|
allWithDataDay: v.querySelectorAll('[data-day]').length,
|
|
buttons: [...v.querySelectorAll('button')].map(b => b.innerText.trim()).slice(0, 14),
|
|
selectors: {}
|
|
};
|
|
// detect the actual class names used for the grid
|
|
const classes = new Set();
|
|
v.querySelectorAll('*').forEach(el => {
|
|
(el.className||'').toString().split(/\\s+/).forEach(c => { if (c) classes.add(c); });
|
|
});
|
|
out.calClasses = [...classes].filter(c => /cal|day|grid|week|cell|todo|task/i.test(c)).slice(0, 30);
|
|
out.text = v.innerText.replace(/\\s+/g,' ').trim().slice(0, 700);
|
|
return out;
|
|
}""")
|
|
print(json.dumps(info, ensure_ascii=False, indent=2))
|
|
print("ERRORS:", errs[:6])
|
|
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/cal_probe.png", full_page=True)
|
|
await b.close()
|
|
|
|
asyncio.run(main()) |