Appearance
Playwright
The playwright template ships headless Chromium with Playwright installed, so an agent can browse, scrape, fill forms and screenshot without a browser ever touching your machine.
Setup
bash
pip install ovrin
export OVRIN_API_KEY="ovrin_..."Take a screenshot
Write the script into the sandbox, run it there, and read the result back:
python
import ovrin
client = ovrin.Client() # reads OVRIN_API_KEY
sandbox = client.sandboxes.create(template="playwright", timeout=900)
sandbox.files.write("/workspace/shot.py", """
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://example.com")
print(page.title())
page.screenshot(path="/workspace/example.png")
browser.close()
""")
result = sandbox.run("python /workspace/shot.py", timeout=300)
print(result.stdout) # Example Domain
# Binary files come back as bytes.
png = sandbox.files.read_bytes("/workspace/example.png")
open("example.png", "wb").write(png)
sandbox.kill()Scrape a page
python
sandbox.files.write("/workspace/scrape.py", """
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
page = p.chromium.launch().new_page()
page.goto("https://example.com")
for link in page.query_selector_all("a"):
print(link.get_attribute("href"))
""")
print(sandbox.run("python /workspace/scrape.py").stdout)Egress is default-deny
A sandbox reaches only the hosts its tenant policy allows. A scraper that wanders somewhere it should not gets a connection failure rather than a surprise on the invoice. See Secure sandboxes.
Related
- Chrome — a Chromium sandbox with remote DevTools
- Agent environments — every template