fix: Parse actual image URLs from search HTML for thumbnails

Extract main_image from HTML img tags instead of constructing from
car_no pattern. Handles timestamp-based filenames (e.g., 1767925381_0.jpg)
that differ from the default cmcar_0.jpg pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AutonetSellCar Deploy
2026-04-02 12:53:37 +09:00
parent f01abfa15e
commit 234f91a14a

View File

@@ -516,9 +516,23 @@ class CarmodooClient:
except:
pass
# 이미지 URL 생성
car_no_padded = car_no.zfill(9)
main_image = f"{CARMODOO_BASE_URL}/data/__carPhoto/{car_no_padded[:3]}/{car_no_padded[3:6]}/{car_no_padded[6:]}/cmcar_0.jpg"
# 이미지 URL: HTML img 태그에서 실제 URL 추출 (타임스탬프 패턴 대응)
main_image = ""
img_elems = row.xpath('.//img[contains(@src, "__carPhoto")]/@src')
if img_elems:
img_src = img_elems[0]
# __THUM 접미사 제거하여 원본 이미지 URL 생성
img_src = img_src.replace('__THUM', '')
if img_src.startswith('/'):
main_image = f"{CARMODOO_BASE_URL}{img_src}"
elif img_src.startswith('http'):
main_image = img_src
else:
main_image = f"{CARMODOO_BASE_URL}/{img_src}"
if not main_image:
# 폴백: 기존 패턴
car_no_padded = car_no.zfill(9)
main_image = f"{CARMODOO_BASE_URL}/data/__carPhoto/{car_no_padded[:3]}/{car_no_padded[3:6]}/{car_no_padded[6:]}/cmcar_0.jpg"
# 성능점검번호 및 key 추출 시도
check_num = ""