extract_after_click
Extract content from web pages by first clicking an element to reveal dynamic content, then scraping specified elements for development workflows.
Instructions
Click an element and extract content from another element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to scrape | |
| clickSelector | Yes | CSS selector of element to click | |
| extractSelector | Yes | CSS selector of element to extract |
Implementation Reference
- src/scrapers/dynamic-scraper.ts:274-296 (handler)Core handler implementation: Navigates to the URL using Playwright, clicks the specified element, waits for the target element to appear, extracts its text content, and returns it.async extractAfterClick(config: ScrapingConfig, clickSelector: string, extractSelector: string): Promise<string> { const browser = await this.getBrowser(); const page = await browser.newPage(); try { await page.goto(config.url, { waitUntil: 'networkidle', timeout: config.timeout || 30000, }); await page.click(clickSelector); await page.waitForTimeout(1000); await page.waitForSelector(extractSelector, { timeout: config.waitForTimeout || 10000, }); const text = await page.textContent(extractSelector); return text || ''; } finally { await page.close(); } }
- src/tools/web-scraping.ts:373-378 (handler)Dispatcher handler case: Parses input parameters and calls the DynamicScraper.extractAfterClick method.case 'extract_after_click': { const clickSelector = params.clickSelector as string; const extractSelector = params.extractSelector as string; const content = await dynamicScraper.extractAfterClick(config, clickSelector, extractSelector); return { content }; }
- src/tools/web-scraping.ts:246-263 (schema)Input schema defining the parameters: url, clickSelector, and extractSelector.inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to scrape', }, clickSelector: { type: 'string', description: 'CSS selector of element to click', }, extractSelector: { type: 'string', description: 'CSS selector of element to extract', }, }, required: ['url', 'clickSelector', 'extractSelector'], },
- src/tools/web-scraping.ts:243-264 (registration)Tool registration in the webScrapingTools array, including name, description, and input schema.{ name: 'extract_after_click', description: 'Click an element and extract content from another element', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to scrape', }, clickSelector: { type: 'string', description: 'CSS selector of element to click', }, extractSelector: { type: 'string', description: 'CSS selector of element to extract', }, }, required: ['url', 'clickSelector', 'extractSelector'], }, },