49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
|
|
#!/usr/bin/env tsx
|
||
|
|
/**
|
||
|
|
* Show detailed output from a successful French parse
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { GenericScraper } from '../../src/scrapers/strategies/generic';
|
||
|
|
|
||
|
|
async function showSuccess() {
|
||
|
|
// One of our successful churches with 16 schedules
|
||
|
|
const url = 'https://laportelatine.org/lieux/couvent-saint-francois-morgon';
|
||
|
|
console.log(`Detailed parse of: ${url}\n`);
|
||
|
|
|
||
|
|
const scraper = new GenericScraper();
|
||
|
|
await scraper.init();
|
||
|
|
scraper.setCountry('FR');
|
||
|
|
|
||
|
|
const result = await scraper.scrape(url);
|
||
|
|
|
||
|
|
console.log(`✅ Success: ${result.success}`);
|
||
|
|
console.log(`📅 Schedules found: ${result.schedules.length}\n`);
|
||
|
|
|
||
|
|
// Group by day
|
||
|
|
const byDay: Record<number, typeof result.schedules> = {};
|
||
|
|
for (const sched of result.schedules) {
|
||
|
|
if (!byDay[sched.dayOfWeek]) byDay[sched.dayOfWeek] = [];
|
||
|
|
byDay[sched.dayOfWeek].push(sched);
|
||
|
|
}
|
||
|
|
|
||
|
|
const dayNames = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
|
||
|
|
|
||
|
|
console.log('═══════════════════════════════════════════════');
|
||
|
|
console.log('PARSED SCHEDULE:');
|
||
|
|
console.log('═══════════════════════════════════════════════\n');
|
||
|
|
|
||
|
|
Object.entries(byDay)
|
||
|
|
.sort(([a], [b]) => parseInt(a) - parseInt(b))
|
||
|
|
.forEach(([day, scheds]) => {
|
||
|
|
console.log(`${dayNames[parseInt(day)]}:`);
|
||
|
|
scheds.forEach(s => {
|
||
|
|
console.log(` ${s.time} - ${s.language} ${s.massType}`);
|
||
|
|
});
|
||
|
|
console.log('');
|
||
|
|
});
|
||
|
|
|
||
|
|
await scraper.close();
|
||
|
|
}
|
||
|
|
|
||
|
|
showSuccess().catch(console.error);
|