Skip to content

Copyable Recipes ​

Every recipe below targets public test pages so you can run them immediately via MCP, CLI or the official SDKs.

1. Scrape GitHub Topic Cards to CSV ​

python
import csv
from browserpilot import launch

with launch() as bp:
    page = bp.new_page()
    page.goto("https://github.com/topics/browser-automation")
    page.locator("article").wait_for(timeout=20)

    rows = page.evaluate("""(() =>
      [...document.querySelectorAll('article')].slice(0, 5).map(card => {
        const repo = (card.querySelector('h3')?.innerText || '').replace(/\\s+/g, ' ').trim();
        const desc = (card.querySelector('p')?.innerText || '').trim();
        return [repo, desc];
      })
    )()""")

    with open("github-topics.csv", "w", newline="", encoding="utf-8-sig") as f:
        writer = csv.writer(f)
        writer.writerow(["Repository", "Description"])
        writer.writerows(rows)
    page.unlock()
text
tab_open    { "url": "https://github.com/topics/browser-automation" }
page_wait   { "selector": "article", "timeout": 20 }
page_script { "source": "(() => [...document.querySelectorAll('article')].slice(0, 5).map(c => [(c.querySelector('h3')?.innerText || '').replace(/\\s+/g, ' ').trim(), (c.querySelector('p')?.innerText || '').trim()]))()" }
page_unlock {}

2. Fill a Form and Wait for the Echo Response ​

Uses untilSelector on page_click so no hardcoded sleep is needed:

text
tab_open    { "url": "https://httpbin.org/forms/post" }
page_wait   { "selector": "input[name=custname]", "timeout": 15 }
page_type   { "label": "Customer name", "text": "BrowserPilot Demo" }
page_type   { "selector": "input[name=custemail]", "text": "demo@browserpilot.dev" }
page_click  { "selector": "input[name=size][value=large]" }
page_click  { "selector": "input[name=topping][value=cheese]" }
page_click  { "selector": "button", "untilSelector": "pre" }
page_script { "source": "JSON.parse(document.querySelector('pre').innerText).form" }
page_unlock {}

3. Click Canvas Targets via shotId Coordinate Grid ​

When a canvas editor or map has no DOM selector, pass the shotId returned by page_screenshot straight back to page_click — BrowserPilot handles crop origin and DPR scaling automatically:

text
page_screenshot { "grid": 50 }
page_click      { "shotId": "shot-returned-id", "x": 520, "y": 340 }

To capture a composited preview of the entire app window (tab strip, address bar, overlay and popups):

text
window_preview  { "grid": 100 }

4. Create an Isolated Environment with Custom Proxy & Timezone ​

text
env_create  { "name": "US Storefront", "remark": "Dedicated proxy and New York timezone" }
network_set {
  "env": "env-created-id",
  "proxy": { "mode": "fixed", "rules": "http://127.0.0.1:7890" },
  "timezone": "America/New_York",
  "acceptLanguages": "en-US,en",
  "webrtcPolicy": "disable_non_proxied_udp"
}
tab_open    { "env": "env-created-id", "url": "https://browserleaks.com/ip" }

5. Zero-Token Scheduled Runs with CLI ​

Save a workflow named "GitHub digest" taking a topic parameter, then create task.json:

json
{
  "name": "GitHub digest",
  "inputs": {
    "topic": "browser-automation"
  }
}

Trigger it from cron (macOS / Linux) or Windows Task Scheduler:

bash
browserpilot call workflow_run --json-file /path/to/task.json

If BrowserPilot is not open yet, the CLI launches it automatically and waits up to 45 seconds before running the workflow.