スクレイピングするプログラムを走らせてたらなんか止まってたので作った。
プログラムが走っている際にWebDriverを更新する人向け。
from selenium import webdriver
def chrome_driver(options=['--headless']):
"""FileNotFoundErrorがたまに起こったりする人向け。
エラーが続く場合は無限ループ。
戻り値はWebDriver(Chrome)"""
chrome_options = webdriver.ChromeOptions()
for option in options:
chrome_options.add_argument(option)
while True:
try:
return webdriver.Chrome(options=chrome_options)
except Exception as e:
# 無限ループ注意
pass