browser_set_content

Browser Set Content

Set the page's HTML content directly. Replaces the current page content with the provided HTML. The page URL will be 'about:blank'. Useful for rendering HTML templates, testing, or injecting content without making a network request.

Usage Example

CURL

curl -X POST \
 -H "Authorization: Bearer <token>" \
 -H "Content-Type: application/json" \
 -d '{
"context_id": "ctx_000001",
"html": "<html>"
}' \
http://localhost:8080/api/execute/browser_set_content

Python SDK

import asyncio
from owl_browser import OwlBrowser, RemoteConfig

# Async usage
async with OwlBrowser(config) as browser:
    context = await browser.create_context()
    context_id = context["context_id"]
    await browser.set_content(
        context_id=context_id,
        html="value"
    )

Node.js SDK

import { OwlBrowser } from '@olib-ai/owl-browser-sdk';

// Async usage
const ctx = await browser.createContext();
const contextId = ctx.context_id;
await browser.setContent({
    context_id: contextId,
    html: 'value'
});

Parameters

Required

  • context_id string required
    The unique identifier of the browser context (e.g., 'ctx_000001')
  • html string required
    The HTML content to set as the page body. Can be a full HTML document or a fragment. The page URL will be set to 'about:blank'

Response

Returns a JSON object with the operation result.

{
  "success": true,
  "result": <value>
}