diff --git a/data/weather_capture.py b/data/weather_capture.py index 6c8b2f9..47b9a4b 100644 --- a/data/weather_capture.py +++ b/data/weather_capture.py @@ -9,6 +9,8 @@ import os import time import tempfile +from config import TODAY + # 크롬 옵션 설정 options = Options() options.add_argument('--headless') @@ -55,16 +57,14 @@ try: driver.quit() exit(1) - time.sleep(2) # 페이지 반영 대기 - - # 캡처 대상 요소 대기 후 찾기 + # 캡처 대상 요소가 확실히 나타날 때까지 명시적 대기 target_element = wait.until(EC.presence_of_element_located( (By.XPATH, '/html/body/div[2]/section/div/div[2]') )) + # 저장 경로 설정 - timestamp = datetime.now().strftime('%Y%m%d') - save_path = os.path.join(script_dir, f'weather_capture_{timestamp}.png') + save_path = os.path.join(script_dir, f'weather_capture_{TODAY}.png') # 요소 스크린샷 저장 target_element.screenshot(save_path)