ajustes scheduling

This commit is contained in:
2025-03-14 12:35:16 +01:00
parent aa974a33ea
commit 4ab39539bc
4 changed files with 46 additions and 10 deletions

View File

@ -10,7 +10,9 @@ Base.metadata.create_all(bind=engine)
# Configurar el scheduler
scheduler = BackgroundScheduler()
scheduler.add_job(search_from_keywords_file, "cron", hour=1, minute=0) #Ejecutar a las 01:00
scheduler.add_job(search_from_keywords_file, "cron", hour=11, minute=0) #Ejecutar a las 01:00
scheduler.add_job(search_from_keywords_file, "cron", hour=18, minute=0) #Ejecutar a las 01:00
@asynccontextmanager
async def lifespan(app: FastAPI):
@ -23,3 +25,4 @@ app = FastAPI(lifespan=lifespan)
# Incluir rutas
app.include_router(router)

View File

@ -94,7 +94,7 @@ def search_news(query):
articles = soup.find_all("item")
news_list = []
for article in articles[:20]: # Limitar a los primeros 20 artículos
for article in articles[:12]: # Limitar a los primeros 12 artículos
try:
title = article.title.get_text(strip=True)
content = article.description.get_text(strip=True) if article.description else "Sin descripción"
@ -184,4 +184,3 @@ def search_from_keywords_file():
logging.info(f"Error al leer el archivo 'keywords.txt': {e}")
# Ejecutar la búsqueda desde el archivo