feat: add overseas financial news and indices support

This commit is contained in:
2026-01-26 03:45:19 +09:00
parent 2fafce0327
commit 3d0dd24f27
3 changed files with 199 additions and 50 deletions

View File

@@ -3,7 +3,7 @@ from fastapi import FastAPI
from apscheduler.schedulers.background import BackgroundScheduler
from .db import init_db, save_articles, get_latest_articles
from .scraper import fetch_market_news, fetch_major_indices
from .scraper import fetch_market_news, fetch_major_indices, fetch_overseas_news
app = FastAPI()
scheduler = BackgroundScheduler(timezone=os.getenv("TZ", "Asia/Seoul"))
@@ -23,18 +23,26 @@ def on_startup():
def run_scraping_job():
print("[StockLab] Starting news scraping...")
articles = fetch_market_news()
count = save_articles(articles)
print(f"[StockLab] Saved {count} new articles.")
# 1. 국내
articles_kr = fetch_market_news()
count_kr = save_articles(articles_kr)
# 2. 해외
articles_world = fetch_overseas_news()
count_world = save_articles(articles_world)
print(f"[StockLab] Saved {count_kr} domestic, {count_world} overseas articles.")
@app.get("/health")
def health():
return {"ok": True}
@app.get("/api/stock/news")
def get_news(limit: int = 20):
"""최신 주식 뉴스 조회"""
return get_latest_articles(limit)
@app.get("/api/stock/news")
def get_news(limit: int = 20, category: str = None):
"""최신 주식 뉴스 조회 (category: 'domestic' | 'overseas')"""
return get_latest_articles(limit, category)
@app.get("/api/stock/indices")
def get_indices():