From 2383f6ebb690fd5be85363469848e2be1ffc5fdc Mon Sep 17 00:00:00 2001 From: KWON Date: Fri, 27 Jun 2025 13:31:30 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=8A=98=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=EC=9D=84=20=EA=B3=B5=ED=86=B5=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95,=20=EB=8C=80=EA=B8=B0=20=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=20=EC=A7=80=EC=A0=95=20=EB=B0=A9=EC=8B=9D=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EA=B0=B1=EC=8B=A0=EB=90=A0=20=EB=95=8C=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=EB=8C=80=EA=B8=B0=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/weather_capture.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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)