Skip to main content
Glama

pilot_page_html

Extract HTML content from web pages using CSS selectors or retrieve full page HTML for web scraping and automation tasks.

Instructions

Get innerHTML of a selector/ref, or full page HTML if none provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoElement ref or CSS selector

Implementation Reference

  • The handler function for the `pilot_page_html` tool, which retrieves either a specific element's innerHTML or the full page content using Playwright.
    server.tool(
      'pilot_page_html',
      'Get innerHTML of a selector/ref, or full page HTML if none provided.',
      { ref: z.string().optional().describe('Element ref or CSS selector') },
      async ({ ref }) => {
        await bm.ensureBrowser();
        try {
          const page = bm.getPage();
          if (ref) {
            const resolved = await bm.resolveRef(ref);
            if ('locator' in resolved) {
              const html = await resolved.locator.innerHTML({ timeout: 5000 });
              return { content: [{ type: 'text' as const, text: html }] };
            }
            const html = await page.innerHTML(resolved.selector);
            return { content: [{ type: 'text' as const, text: html }] };
          }
          const html = await page.content();
          return { content: [{ type: 'text' as const, text: html }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
        }
      }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TacosyHorchata/Pilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server