본문 바로가기

오늘 배운 내용

[Python]파이썬 라이브러리 : 크롬드라이버 자동설치 chromedriver-autoinstaller

공부한 것


  • 크롬 드라이버 자동 설치하는 라이브러리
  • selenium에서 quit()함수 : 마지막에 크롬드라이버 모두 닫아주는 함수 ⇒ 사용해줘야하는 이유는 컴퓨터 메모리 누수 방지

selenium을 이용하여 exe 파일을 만들고 난뒤 배포하고 나서, 다른 컴퓨터에서 사용할 시에 따로 크롬드라이버를 설치해줘야하는 번거러움이 있었다.

그 번거로움을 대체하여서 찾다 보니 자동설치 라이브러리를 찾게 되었다.

chromedriver_autoinstaller 라는 라이브러리

참고 사이트 [https://pypi.org/project/chromedriver-autoinstaller/]

설치 방법

  • pip install chromedriver-autoinstaller

사용법

from selenium import webdriver
import chromedriver_autoinstaller

path = chromedriver_autoinstaller.install()
# Check if the current version of chromedriver exists
# and if it doesn't exist, download it automatically,
# then add chromedriver to path

driver = webdriver.Chrome(path)
driver.get("https://leonslife.tistory.com")

driver.close()
driver.quit()