-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
크롬드라이버 업데이트 관련
23.08.21 13:36 작성 조회수 388
0
안녕하세요. 스타트 코딩님,
크롬 버전(Version 116.0.5845.96)을 업그레이드 한 이후로 셀레니움을 통해 크롬 드라이버를 자동으로 Install 하지 못하는 상황이 반복되고 있습니다.
이 경우에는 어떻게 해야 될까요?
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
# 크롬 드라이버 자동 업데이트
from webdriver_manager.chrome import ChromeDriverManager
import time
import pyautogui
import pyperclip
# 브라우저 꺼짐 방지 코드
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
# 불필요한 에러 메세지 없기
chrome_options.add_experimental_option("excludeSwitches", ['enable-logging'])
servie = Service(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=servie, options=chrome_options)
driver.get("https://shopping.naver.com/home")
답변을 작성해보세요.
0
logan1i
질문자2023.08.23
안녕하세요, 혹시 강의 설명란에 코들 참고 했는데도 안되고 크롬 드라이버를 다운 받아서 코드를 작성해보았는데도 안되면 또 다른 방법이 있을까요?
import os, time
from selenium import webdriver
import chromedriver_autoinstaller
def chrome_driver():
options = webdriver.ChromeOptions()
chrome_ver = chromedriver_autoinstaller.get_chrome_version()
print(f'현재 버전: {chrome_ver}')
chromedriver = f'./{chrome_ver.split(".")[0]}/chromedriver.exe'
if not os.path.exists(chromedriver):
os.makedirs(os.path.dirname(chromedriver), exist_ok=True)
res = chromedriver_autoinstaller.install(True)
if res:
print(f'설치 완료({chrome_ver.split(".")[0]} 버전')
else:
print(f'설치 오류 발생({chrome_ver.split(".")[0]} 버전)')
driver = webdriver.Chrome(chromedriver, options=options)
return driver
driver = chrome_driver()
time.sleep(3)
driver.quit()
답변 1