from fastapi import FastAPI from newspaper import Article from bs4 import BeautifulSoup import requests app = FastAPI() @app.get("/peruvian_soccer_news") def get_news(): url = "https://ovacion.pe/" # Replace with actual URL response = requests.get(url) soup = BeautifulSoup(response.content, "html.parser") # Example: Extract headlines and links articles = [] for item in soup.select(".news-item"): # Adjust to match actual site structure title = item.select_one(".headline").get_text(strip=True) link = item.select_one("a")["href"] articles.append({"title": title, "link": link}) return {"articles": articles}