28 lines
No EOL
1.4 KiB
Python
28 lines
No EOL
1.4 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":1600,"height":1100})
|
|
errs = []
|
|
pg.on("pageerror", lambda e: errs.append(f"PAGEERR {e}"))
|
|
pg.on("console", lambda m: errs.append(f"CONSOLE[{m.type}] {m.text}") if m.type in ("error","warning") else None)
|
|
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
|
|
await pg.wait_for_timeout(3000)
|
|
r = await pg.evaluate("""async () => {
|
|
const out = {};
|
|
out.hasLoadTeam = typeof loadTeam;
|
|
out.hasTeamData = typeof TEAM_DATA;
|
|
try { out.teamDataValue = String(TEAM_DATA); } catch(e) { out.teamDataErr = String(e); }
|
|
try { await loadTeam(); out.called = true; } catch(e) { out.callErr = String(e); }
|
|
await new Promise(r=>setTimeout(r,2500));
|
|
out.cards = document.querySelectorAll('#teamCards .card').length;
|
|
out.meta = document.getElementById('teamMeta')?.innerText.slice(0,90);
|
|
return out;
|
|
}""")
|
|
print(json.dumps(r, ensure_ascii=False, indent=2))
|
|
print("ERRORS:", json.dumps(errs[:8], ensure_ascii=False, indent=2))
|
|
await b.close()
|
|
|
|
asyncio.run(main()) |