Scraping Service and types
This commit is contained in:
@ -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) {}
|
||||
|
36
src/types/NewspaperTypes.ts
Normal file
36
src/types/NewspaperTypes.ts
Normal 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[];
|
||||
}
|
Reference in New Issue
Block a user