17 lines
902 B
Python
17 lines
902 B
Python
from playwright.sync_api import sync_playwright
|
|
import os
|
|
OUT = os.path.abspath("shots"); os.makedirs(OUT, exist_ok=True)
|
|
with sync_playwright() as p:
|
|
b = p.chromium.launch(headless=True)
|
|
pg = b.new_context(viewport={"width":1440,"height":900}).new_page()
|
|
pg.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000)
|
|
for y in range(0, pg.evaluate("document.body.scrollHeight"), 400):
|
|
pg.evaluate(f"window.scrollTo(0,{y})"); pg.wait_for_timeout(80)
|
|
pg.evaluate("window.scrollTo(0,0)"); pg.wait_for_timeout(800)
|
|
for sel, name in [(".flow","sec-flow"),(".proof","sec-proof"),(".reviews","sec-reviews"),(".band:first-of-type","sec-band")]:
|
|
el = pg.query_selector(sel)
|
|
if el:
|
|
el.scroll_into_view_if_needed(); pg.wait_for_timeout(400)
|
|
el.screenshot(path=os.path.join(OUT, name+".png")); print("OK", name)
|
|
b.close()
|