Skip to main content
Glama
josuekongolo

CompanyIQ MCP Server

by josuekongolo
test-openai-scraper.js3.66 kB
import { BrowserScraper } from './build/scraper/browser_scraper.js'; // Set OpenAI API key const OPENAI_API_KEY = "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"; async function testOpenAIScraper() { console.log('🚀 Testing Browser + OpenAI PDF Scraper'); console.log('═'.repeat(50)); console.log('This will:'); console.log('1. Open a browser and download ALL årsregnskap PDFs'); console.log('2. Use OpenAI GPT-4 Vision to extract financial data'); console.log('═'.repeat(50)); // Test company (use a different one if you want) const orgNr = '999059198'; // KONGOLO CONSULTING AS console.log(`\n📊 Testing with company: ${orgNr}`); console.log('─'.repeat(50) + '\n'); const scraper = new BrowserScraper(OPENAI_API_KEY); try { const startTime = Date.now(); // Get all financial years const results = await scraper.getAllFinancialYears(orgNr); const duration = Math.round((Date.now() - startTime) / 1000); console.log('\n' + '═'.repeat(50)); console.log('📊 ALL FINANCIAL YEARS EXTRACTED'); console.log('═'.repeat(50)); console.log(`\n✅ Total years found: ${results.length}`); console.log(`⏱️ Time taken: ${duration} seconds\n`); // Display all years results.forEach(year => { console.log(`📅 Year ${year.year}:`); if (year.revenue || year.profit || year.assets || year.equity) { if (year.revenue) console.log(` 💰 Revenue: ${(year.revenue / 1000000).toFixed(1)}M NOK`); if (year.profit !== null) console.log(` 📊 Profit: ${(year.profit / 1000000).toFixed(1)}M NOK`); if (year.assets) console.log(` 🏢 Assets: ${(year.assets / 1000000).toFixed(1)}M NOK`); if (year.equity) console.log(` 💎 Equity: ${(year.equity / 1000000).toFixed(1)}M NOK`); console.log(` 📄 Source: ${year.source}`); } else { console.log(` ⚠️ No data extracted (PDF might be encrypted or unreadable)`); } console.log(''); }); // Summary statistics const yearsWithData = results.filter(r => r.revenue !== null || r.profit !== null || r.assets !== null || r.equity !== null ).length; console.log('═'.repeat(50)); console.log('📈 SUMMARY STATISTICS'); console.log('═'.repeat(50)); console.log(`Total years available: ${results.length}`); console.log(`Years with extracted data: ${yearsWithData}`); console.log(`Success rate: ${((yearsWithData / results.length) * 100).toFixed(1)}%`); // Show year range if (results.length > 0) { const years = results.map(r => r.year).sort((a, b) => a - b); console.log(`Year range: ${years[0]} - ${years[years.length - 1]}`); } console.log('\n✅ Test completed successfully!'); // Check if we got ALL years (should be more than 3) if (results.length <= 3) { console.log('\n⚠️ WARNING: Only found ' + results.length + ' years.'); console.log('Expected to find more years (2012-2024 range).'); console.log('The "Vis flere" button clicking might need adjustment.'); } else { console.log('\n🎉 SUCCESS: Found ' + results.length + ' years of financial data!'); } } catch (error) { console.error('\n❌ Test failed:', error); console.error('\nMake sure:'); console.error('1. Chrome is installed at /Applications/Google Chrome.app'); console.error('2. The OpenAI API key is valid'); console.error('3. You have internet connection'); } } // Run the test testOpenAIScraper();

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/josuekongolo/companyiq-mcp'

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