Example: Screenshots
Save full-page screenshots as PNG files.
Code
import asynciofrom pathlib import Path
from voidcrawl import BrowserPool, PoolConfig
OUTPUT_DIR = Path("output")
async def _capture() -> None: async with BrowserPool(PoolConfig()) as pool, pool.acquire() as tab: await tab.goto("https://qscrape.dev")
# PNG screenshot png_bytes = await tab.screenshot_png() png_path = OUTPUT_DIR / "example.png" png_path.write_bytes(png_bytes) print(f"Screenshot saved: {png_path} ({len(png_bytes)} bytes)")
def main() -> None: OUTPUT_DIR.mkdir(exist_ok=True) asyncio.run(_capture())
if __name__ == "__main__": main()Key Points
screenshot_png()returns raw PNG bytes — write them to a file withPath.write_bytes().- Screenshots capture the full visible viewport as rendered by Chrome.
- For headful Docker mode, you can watch the page render in VNC while the screenshot is captured.