Scraping Service and types

This commit is contained in:
albert
2025-07-29 12:46:20 +02:00
parent d8381c893d
commit ced2254068
2 changed files with 38 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { IFeedRepository } from '../repositories/FeedRepository';
import { IFeed } from '../types/Feed';
import { IFeedRepository } from '../repositories/FeedRepository.js';
import { IFeed } from '../types/Feed.js';
export class ScrapingService {
constructor(private feedRepository: IFeedRepository) {}

View File

@ -0,0 +1,36 @@
import { NewsSource } from './Feed.js';
import { IFeed } from './Feed.js';
/**
* Interfaz para definir la configuración de extracción de un periódico
*/
export interface NewspaperConfig {
name: string;
source: NewsSource;
baseUrl: string;
frontPageUrl: string;
selectors: NewsSelectors;
enabled: boolean;
}
/**
* Selectores CSS para extraer elementos específicos de cada periódico
*/
export interface NewsSelectors {
articleLinks: string;
titleSelector?: string;
descriptionSelector?: string;
dateSelector?: string;
imageSelector?: string;
}
/**
* Resultado del proceso de scraping
*/
export interface ScrapingResult {
success: number;
failed: number;
duplicates: number;
items: (IFeed | null)[];
errors: string[];
}