import axios from 'axios'; import * as cheerio from 'cheerio'; const baseUrl = 'https://etendersni.gov.uk'; // Try different potential URLs for the tenders list const urls = [ '/api/search', '/epps/home.do', '/epps/viewInfo.do?section=newItems', '/epps/viewInfo.do?section=notices', ]; (async () => { for (const path of urls) { try { const url = baseUrl + path; console.log(`\n=== Trying ${path} ===`); const resp = await axios.get(url, { timeout: 8000 }); const $ = cheerio.load(resp.data); // Look for any links with entryId or that look like tender details const tenderLinks = []; $('a').each((i, el) => { const href = $(el).attr('href'); const text = $(el).text().trim(); if (href && ( href.includes('entryId') || href.includes('viewInfo') || href.includes('viewNotice') || href.includes('detail') || href.includes('tender') || text.match(/procurement|tender|notice|opportunity/i) )) { const fullUrl = href.startsWith('http') ? href : baseUrl + (href.startsWith('/') ? href : '/epps/' + href); tenderLinks.push({ text: text.substring(0, 50), href: fullUrl }); } }); if (tenderLinks.length > 0) { console.log(`Found ${tenderLinks.length} potential tender links`); tenderLinks.slice(0, 5).forEach(l => { console.log(` "${l.text}" => ${l.href}`); }); } } catch (e) { console.log(`Error: ${e.message.split('\n')[0]}`); } } })();