Examples
Wait before taking screenshot with Python and Puppeteer
Heads up before you start
Puppeteer has no official Python port. The community port, pyppeteer, is no longer maintained and bundles an old Chromium. These examples still work, but for new projects we recommend Playwright for Python — it covers everything Puppeteer does and is actively maintained.
Install the Python Puppeteer port and Chromium
pip install pyppeteer
pyppeteer-install Take a screenshot and save to file
Wait for the page to settle before taking the screenshot.
import asyncio
from pyppeteer import launch
async def main():
browser = await launch()
page = await browser.newPage()
await page.goto('https://www.htmltoimage.com/demo')
await asyncio.sleep(3)
await page.screenshot({'path': 'wait.png'})
await browser.close()
asyncio.run(main()) Find out how to take a full-page screenshot with Python and Puppeteer.
That was 12 lines of code — plus a browser to run in production
Keeping headless browsers fed, patched and scaled is a job in itself. We built Urlbox so the same screenshot is one API call:
curl "https://api.urlbox.com/v1/YOUR_API_KEY/png?url=https://example.com" Try the Urlbox screenshot API — free trial, no browser babysitting.