오늘 날짜 부분을 공통으로 사용하도록 수정, 대기 시간 지정 방식에서 갱신될 때까지 대기하도록 수정.
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user