html = driver.page_source
dom = BeautifulSoup(html, 'html.parser')
contents = dom.select('#placesList li')
len(contents)
원인
selenium webdriver는 페이지에서 발생하는 알림창을 자동으로 처리하지 못함 = 예상치 못한 알림창 나타날때 자주 발생
해결 방법
방법 1) 알림창을 닫거나 텍스트를 확인하도록 설정
방법 2) 예외처리를 통해 프로그램을 매끄럽게 진행시킴
- Alert 핸들링
try: wait.until(EC.alert_is_present()) alert = Alert(driver) alert_text = alert.text # Alert의 내용을 읽어옴 alert.accept() shared_queue.put(f'{alert_text}\n') time_sleep() driver.switch_to.window(all_window_handles[0]) driver.switch_to.default_content() # 프레임 전환 continue
잘 봤습니다. 좋은 글 감사합니다.