fix: update overseas news API url and key mapping

This commit is contained in:
2026-01-26 04:03:09 +09:00
parent 0e2d241e18
commit 9faa1c5715

View File

@@ -80,7 +80,7 @@ def fetch_overseas_news() -> List[Dict[str, str]]:
"""
네이버 금융 해외증시 뉴스 크롤링 (모바일 API 사용)
"""
api_url = "https://m.stock.naver.com/api/news/list/global?pageSize=20&page=1"
api_url = "https://api.stock.naver.com/news/overseas/category/breaking?pageSize=20&page=1"
try:
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)"
@@ -96,9 +96,10 @@ def fetch_overseas_news() -> List[Dict[str, str]]:
articles = []
for item in items:
title = item.get("subject", "")
summary = item.get("summary", "")
press = item.get("officeName", "")
# API 키 매핑 (subject/title/tit, summary/subContent/sub_tit 등)
title = item.get("subject") or item.get("title") or item.get("tit") or ""
summary = item.get("summary") or item.get("subContent") or item.get("sub_tit") or ""
press = item.get("officeName") or item.get("office_name") or item.get("cp_name") or ""
# 날짜 포맷팅 (20260126123000 -> 2026-01-26 12:30:00)
raw_dt = str(item.get("dt", ""))