Examples
Retina screenshots with Python and Playwright
Install Playwright and the Playwright client for Python
pip install playwright
playwright install chromium Take a retina screenshot and save to file
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
context = browser.new_context(
viewport={'width': 480, 'height': 240},
device_scale_factor=2,
)
page = context.new_page()
page.goto('https://www.htmltoimage.com/demo')
page.screenshot(path='retina.png')
browser.close() Find out how to take a full-page screenshot with Python and Playwright.
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.