처음에는 Jsoup 라이브러리를 쓰려고 했지만 정적 WebParsing으로 한계가 있다고 하여,
동적으로 컨트롤이 가능한 Selenium을 선택했습니다.
pip3 install selenium
pip3 install selenium==4.4.3
pip3 install --upgrade pip
pip3 install --upgrade selenium
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
service = ChromeService(executable_path=CHROMEDRIVER_PATH)
driver = webdriver.Chrome(service=service, options=options)
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=options)
이전에는 크롬 버전과 일치하는 크롬 드라이버를 별도로 설치해서 PATH를 맞춰줘야하는 불편함이 있었지만, 자동으로 설치해주는 패키지가 나오면서 chromedriver 버전 관리에 더이상 신경 쓸 필요가 없어졌습니다.
pip3 install webdriver-manager
# selenium 4
service = ChromeService(executable_path=CHROMEDRIVER_PATH)
driver = webdriver.Chrome(service=service, options=options)
from webdriver_manager.chrome import ChromeDriverManager
service = ChromeService(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=options)
pip3 install chromedriver_autoinstaller