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":950}).new_page() pg.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000) for y in range(0, pg.evaluate("document.body.scrollHeight"), 380): pg.evaluate(f"window.scrollTo(0,{y})"); pg.wait_for_timeout(70) pg.evaluate("window.scrollTo(0,0)"); pg.wait_for_timeout(700) for sel,name in [(".svc","c2-acc"),(".faq","c2-faq"),(".prefooter","c2-form"),(".intro","c2-intro")]: 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()