Add sector classification module, integrate into all 7 scrapers, fix CF pagination
This commit is contained in:
55
etendersni-api.mjs
Normal file
55
etendersni-api.mjs
Normal file
@@ -0,0 +1,55 @@
|
||||
import axios from 'axios';
|
||||
import * as cheerio from 'cheerio';
|
||||
|
||||
const searchUrl = 'https://etendersni.gov.uk/api/search';
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Fetching search page...');
|
||||
const resp = await axios.get(searchUrl, { timeout: 10000 });
|
||||
const $ = cheerio.load(resp.data);
|
||||
|
||||
console.log('=== PAGE STRUCTURE ===');
|
||||
console.log('Title:', $('title').text());
|
||||
|
||||
console.log('\n=== FORMS ===');
|
||||
$('form').each((i, el) => {
|
||||
const action = $(el).attr('action');
|
||||
const method = $(el).attr('method');
|
||||
const id = $(el).attr('id');
|
||||
console.log(`Form ${i}: method=${method} action=${action} id=${id}`);
|
||||
|
||||
// Look for inputs
|
||||
$(el).find('input, select, textarea').each((j, inp) => {
|
||||
const name = $(inp).attr('name');
|
||||
const type = $(inp).attr('type');
|
||||
const value = $(inp).attr('value');
|
||||
console.log(` Input: name=${name} type=${type} value=${value}`);
|
||||
});
|
||||
});
|
||||
|
||||
console.log('\n=== TABLES/RESULTS ===');
|
||||
const tables = $('table');
|
||||
console.log('Found', tables.length, 'tables');
|
||||
|
||||
if (tables.length > 0) {
|
||||
const firstTable = tables.eq(0);
|
||||
console.log('\nFirst table rows:');
|
||||
firstTable.find('tr').slice(0, 3).each((i, row) => {
|
||||
const cells = $(row).find('td, th');
|
||||
const text = cells.map((j, cell) => $(cell).text().trim().substring(0, 30)).get();
|
||||
console.log(` Row ${i}:`, text);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('\n=== LINKS IN RESULTS ===');
|
||||
$('a[href*="view"], a[href*="notice"]').slice(0, 10).each((i, el) => {
|
||||
const href = $(el).attr('href');
|
||||
const text = $(el).text().trim().substring(0, 50);
|
||||
console.log(` ${text} => ${href}`);
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error:', e.message);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user