Skip to main content
Glama
josuekongolo

CompanyIQ MCP Server

by josuekongolo
test-browser-scraper.jsβ€’3.2 kB
import dotenv from 'dotenv'; import { BrowserScraper } from './build/scraper/browser_scraper.js'; // Load environment variables from .env file dotenv.config(); async function testBrowserScraper() { console.log('πŸš€ Testing Browser-Based Scraper'); console.log('================================\n'); console.log('This will open a visible browser window and download PDFs.'); console.log('Please do not interact with the browser window.\n'); const scraper = new BrowserScraper(); const orgNr = '999059198'; // Company with multiple years console.log(`πŸ“Š Starting browser automation for company ${orgNr}...\n`); try { const startTime = Date.now(); const results = await scraper.getAllFinancialYears(orgNr); const duration = Math.round((Date.now() - startTime) / 1000); console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log('πŸ“Š BROWSER SCRAPING RESULTS'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); console.log(`βœ… Successfully processed ${results.length} years in ${duration} seconds\n`); // Group results by data availability const withData = results.filter(r => r.revenue !== null || r.profit !== null); const withoutData = results.filter(r => r.revenue === null && r.profit === null); console.log(`πŸ“ˆ Years with financial data: ${withData.length}`); withData.forEach(r => { console.log(` ${r.year}: Revenue=${r.revenue ? (r.revenue/1000000).toFixed(1) + 'M NOK' : 'N/A'}, ` + `Profit=${r.profit ? (r.profit/1000000).toFixed(1) + 'M NOK' : 'N/A'} (${r.source})`); }); if (withoutData.length > 0) { console.log(`\n⚠️ Years without data: ${withoutData.length}`); withoutData.forEach(r => { console.log(` ${r.year}: ${r.source}`); }); } // Summary console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log('πŸ“Š SUMMARY'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); console.log(`Total years found: ${results.length}`); console.log(`Years with data: ${withData.length}`); console.log(`Success rate: ${results.length > 0 ? Math.round(withData.length / results.length * 100) : 0}%`); console.log(`Time taken: ${duration} seconds`); if (duration > 300) { console.log('\n⚠️ WARNING: Took more than 5 minutes'); } else if (duration > 180) { console.log('\n⚠️ Took 3-5 minutes (within expected range)'); } else { console.log('\nβœ… Completed in reasonable time!'); } console.log('\nπŸŽ‰ Browser automation succeeded!'); } catch (error) { console.error('❌ Test failed:', error.message || error); console.error('\nThis might be due to:'); console.error('- Browser automation being blocked'); console.error('- Network issues'); console.error('- Page structure changes'); console.error('- Timeout issues'); } } testBrowserScraper();

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