fix(stock): 원달러 환율 등락 방향 판별 수정
네이버 환율 HTML에 .blind span이 "미국 USD"/"원"/"상승" 3개라
select_one(".blind")이 첫 번째 "미국 USD"를 잡아 방향 추출 실패 →
direction="" + 부호 없는 change_value → 프론트가 항상 상승으로 표시.
해외 지수와 동일하게 .head_info의 point_up/point_dn 클래스로 판별,
직속 .blind 텍스트(상승/하락)를 fallback으로 사용.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -199,11 +199,21 @@ def fetch_major_indices() -> Dict[str, Any]:
|
|||||||
value = usd_item.select_one(".value").get_text(strip=True)
|
value = usd_item.select_one(".value").get_text(strip=True)
|
||||||
change_val = usd_item.select_one(".change").get_text(strip=True)
|
change_val = usd_item.select_one(".change").get_text(strip=True)
|
||||||
|
|
||||||
# 방향 (blind 텍스트: 상승, 하락)
|
# 방향: .head_info의 point_up/point_dn 클래스로 판별 (해외 지수와 동일 패턴).
|
||||||
|
# .blind span이 "미국 USD"/"원"/"상승" 3개라 select_one(".blind")은 첫 번째 "미국 USD"를
|
||||||
|
# 잡아 방향 추출에 실패함 → head_info 클래스를 1순위로, 직속 .blind 텍스트를 fallback으로 사용.
|
||||||
direction = ""
|
direction = ""
|
||||||
blind_txt = usd_item.select_one(".blind").get_text(strip=True)
|
head_info = usd_item.select_one(".head_info")
|
||||||
if "상승" in blind_txt: direction = "red"
|
hi_classes = head_info.get("class", []) if head_info else []
|
||||||
elif "하락" in blind_txt: direction = "blue"
|
if "point_up" in hi_classes:
|
||||||
|
direction = "red"
|
||||||
|
elif "point_dn" in hi_classes:
|
||||||
|
direction = "blue"
|
||||||
|
else:
|
||||||
|
dir_blind = usd_item.select_one(".head_info > span.blind")
|
||||||
|
blind_txt = dir_blind.get_text(strip=True) if dir_blind else ""
|
||||||
|
if "상승" in blind_txt: direction = "red"
|
||||||
|
elif "하락" in blind_txt: direction = "blue"
|
||||||
|
|
||||||
# change_val은 네이버 HTML에서 부호 없이 숫자만 옴 → direction 기반으로 부호 붙여줌
|
# change_val은 네이버 HTML에서 부호 없이 숫자만 옴 → direction 기반으로 부호 붙여줌
|
||||||
# (프론트 getDirection()이 부호로 색/화살표를 판별하므로)
|
# (프론트 getDirection()이 부호로 색/화살표를 판별하므로)
|
||||||
|
|||||||
Reference in New Issue
Block a user