from selenium import webdriver from selenium.webdriver.common.alert import Alert from selenium.common.exceptions import NoAlertPresentException try: # alert 발생 alert = Alert(driver) # alert 확인 버튼 클릭 alert.accept() except NoAlertPresentException: pass 위와같이 크롤링 작동할때 알러트창이 뜨는 경우 확인을 눌러줘야 다음으로 실행되므로 try ~ except를 사용하여 처리하면 편하다.
사이트 크롤링시 alert 발생하는 경우 처리방법
from selenium import webdriver from selenium.webdriver.common.alert import Alert from selenium.common.exceptions import NoAlertPresentException try: # alert 발생 alert = Alert(driver) # alert 확인 버튼 클릭 alert.accept() except NoAlertPresentException: pass 위와같이 크롤링 작동할때 알러트창이 뜨는 경우 확인을 눌러줘야 다음으로 실행되므로 try ~ except를 사용하여 처리하면 편하다.
2023.05.26