debug_scraper
Verify and debug the scraping functionality to ensure accurate retrieval of cryptocurrency airdrop data from DeFiLlama, supporting seamless integration with automation workflows.
Instructions
Debugar o scraper para verificar se está funcionando corretamente
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:280-301 (handler)The primary handler function for the 'debug_scraper' tool. It invokes the scraper's debugPage method, formats the result as MCP content, and handles errors.private async debugScraper() { try { const debugInfo = await this.scraper.debugPage(); return { content: [ { type: 'text', text: `Debug Info:\n${debugInfo}` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Erro no debug: ${error}` } ] }; } }
- src/index.ts:108-115 (schema)The input schema definition for the 'debug_scraper' tool, registered in the ListTools handler. It takes no parameters.{ name: 'debug_scraper', description: 'Debugar o scraper para verificar se está funcionando corretamente', inputSchema: { type: 'object', properties: {} } }
- src/index.ts:134-136 (registration)The switch case in the CallToolRequestSchema handler that routes requests for 'debug_scraper' to the debugScraper handler method.case 'debug_scraper': return await this.debugScraper();
- src/scraper.ts:651-682 (helper)The helper method in DeFiLlamaScraper that performs the actual debugging: fetches the airdrops page, parses with cheerio, extracts structural info, and returns JSON details for debugging the scraper.async debugPage(): Promise<string> { try { console.log('Fazendo debug da página...'); const response = await this.axiosInstance.get('https://defillama.com/airdrops'); const $ = cheerio.load(response.data); const pageInfo = { title: $('title').text(), url: 'https://defillama.com/airdrops', status: response.status, headers: response.headers['content-type'], bodyLength: response.data.length, elementCounts: { total: $('*').length, tables: $('table').length, divs: $('div').length, links: $('a').length, rows: $('tr').length }, sampleText: $('body').text().slice(0, 500), foundStructures: { tableRows: $('table tbody tr').length, airdropElements: $('[class*="airdrop"]').length, itemElements: $('[class*="item"]').length } }; return JSON.stringify(pageInfo, null, 2); } catch (error) { return `Erro no debug: ${error}`; } }