pip install webdriver-manager
で、インストール。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome import service as fs
from webdriver_manager.chrome import ChromeDriverManager
import列に上記で追加して…(太字以外は自身の環境に合わせて)
chrome_service = fs.Service(executable_path=ChromeDriverManager().install())
って感じ。うちの場合は以下な感じ。
chrome_service = fs.Service(executable_path=ChromeDriverManager().install())
ChromeOptions = webdriver.ChromeOptions()
ChromeOptions.add_argument('disable-extensions') # すべての拡張機能を無効にする。ユーザースクリプトも無効にする
ChromeOptions.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(service=chrome_service, options=ChromeOptions)