Guide 03 · templates: playwright, playwright-headed
Browser automation & web scraping for AI agents
Agents that browse need Chromium, and Chromium needs a machine. The
playwright template boots with the browser and drivers installed — write the
script (or let the model write it), run it, download what it found.
1
Create the browser box
from pilldrops import Sandbox sb = Sandbox.create(template="playwright", vcpu=2, memory_mb=2048)
2
Ship the scraping script
script = ''' from playwright.sync_api import sync_playwright with sync_playwright() as p: page = p.chromium.launch().new_page() page.goto("https://news.ycombinator.com") titles = page.locator(".titleline a").all_inner_texts() open("/out/titles.txt","w").write("\\n".join(titles)) ''' sb.files.write("/work/scrape.py", script)
3
Run it and collect results
sb.run("mkdir -p /out && python /work/scrape.py", timeout=120).check() sb.download("/out", "./scraped") sb.kill()
Headed mode: use
playwright-headed when a site needs a visible
browser, and watch it through the sandbox preview URL — useful for debugging agent browsing behavior.≈ $0.13/h (2 vCPU · 2 GB) ·
files API