get_content
Extract rendered HTML content from any webpage by specifying a URL. Optionally wait for specific selectors or JavaScript functions to execute before retrieving the content.
Instructions
Extract rendered HTML content from a webpage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| waitForFunction | No | ||
| waitForSelector | No |
Implementation Reference
- src/client.ts:113-124 (handler)Core handler logic: sends POST request to Browserless /content endpoint to extract rendered HTML from a URL, handles response and errors.async getContent(request: ContentRequest): Promise<BrowserlessResponse<ContentResponse>> { try { const response: AxiosResponse<ContentResponse> = await this.httpClient.post('/content', request); return { success: true, data: response.data, }; } catch (error) { return this.handleError(error); } }
- src/index.ts:345-368 (handler)MCP server handler wrapper: calls client.getContent and formats response as MCP content blocks.case 'get_content': { if (!args) throw new Error('Arguments are required'); const result = await this.client!.getContent(args as any); if (result.success && result.data) { return { content: [ { type: 'text', text: `Content extracted successfully from ${result.data.url}`, }, { type: 'text', text: `Title: ${result.data.title}`, }, { type: 'text', text: result.data.html, }, ], }; } else { throw new Error(result.error || 'Failed to get content'); } }
- src/index.ts:111-134 (registration)Tool registration: defines name, description, and input schema in ListToolsRequestHandler response.name: 'get_content', description: 'Extract rendered HTML content from a webpage', inputSchema: { type: 'object', properties: { url: { type: 'string' }, waitForSelector: { type: 'object', properties: { selector: { type: 'string' }, timeout: { type: 'number' }, }, }, waitForFunction: { type: 'object', properties: { fn: { type: 'string' }, timeout: { type: 'number' }, }, }, }, required: ['url'], }, },
- src/types.ts:151-166 (schema)Zod validation schema for ContentRequest input type.export const ContentRequestSchema = z.object({ url: z.string(), gotoOptions: z.object({ waitUntil: z.string().optional(), timeout: z.number().optional(), }).optional(), waitForSelector: WaitForSelectorSchema.optional(), waitForFunction: WaitForFunctionSchema.optional(), waitForTimeout: z.number().optional(), addScriptTag: z.array(ScriptTagSchema).optional(), headers: z.record(z.string()).optional(), cookies: z.array(CookieSchema).optional(), viewport: ViewportSchema.optional(), }); export type ContentRequest = z.infer<typeof ContentRequestSchema>;
- src/types.ts:265-269 (schema)TypeScript interface for ContentResponse output from getContent.export interface ContentResponse { html: string; url: string; title: string; }