diff --git a/backend/app/api/carmodoo.py b/backend/app/api/carmodoo.py index 3bd2e04..c883772 100644 --- a/backend/app/api/carmodoo.py +++ b/backend/app/api/carmodoo.py @@ -380,7 +380,14 @@ class CarmodooClient: cars = [] try: - tree = lxml_html.fromstring(html) + # HTML 내부의 charset 선언 제거 (이미 UTF-8로 디코딩됨) + html = re.sub(r']*charset[^>]*>', '', html, flags=re.IGNORECASE) + html = re.sub(r'charset\s*=\s*["\']?euc-kr["\']?', 'charset="utf-8"', html, flags=re.IGNORECASE) + + # lxml에 UTF-8 인코딩임을 명시 + from lxml.html import HTMLParser + parser = HTMLParser(encoding='utf-8') + tree = lxml_html.document_fromstring(html.encode('utf-8'), parser=parser) # 각 차량 행 찾기 (tr id="trCtl_XXXXXXX") car_rows = tree.xpath('//tr[starts-with(@id, "trCtl_")]')