from webdriver_manager.chrome import ChromeDriverManager
ChromeDriverManager().install()
前日まで使えてたコードで、急にエラーが出ました。
「packages\webdriver_manager\core\http.py", line 16, in validate_response raise ValueError(f"There is no such driver by url {resp.url}") ValueError: There is no such driver by url https://chromedriver.storage.googleapis.com/115.0.5790/chromedriver_win32.zip」
ChatGPTに聞いてみると、
「このエラーは、指定されたURLからChromeドライバーをダウンロードできないことを示しています。」
とのこと。(提案された対処方法は、効果なし)
一度、手動でドライバーをダウンロードしようと検索したところ、、バージョン115は無い!
恐らくChromeの自動アップデートでバージョン115になったが、Chromeドライバーを探しても見つからず
それでエラーになったのだと思われます。
そこで、ダウンロード可能な最新バージョンのChromeドライバーを、自動的にダウンロードするコードを
ChatGPTに考えてもらいました
# coding: utf-8
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import requests
url = 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE'
response = requests.get(url)
options = Options()
options.add_argument('--headless')# ヘッドレス起動
options.add_argument('--disable-gpu')
options.add_argument('--ignore-certificate-errors')# SSLエラー対策
options.add_argument('--disable-blink-features=AutomationControlled')# webdriver検出を回避
options.add_argument('--blink-settings=imagesEnabled=false')# 画像非表示
## 最新のバージョンのChromeドライバーを取得する
try:
driver_path = ChromeDriverManager().install()
driver = webdriver.Chrome(executable_path=driver_path, options=options)
except ValueError:
# ValueErrorが発生した場合、バージョンを指定してインストール
driver_path = ChromeDriverManager(version=response.text).install()
driver = webdriver.Chrome(executable_path=driver_path, options=options)
自分の環境では上記コードで実行出来ました
お役に立てれば、幸いです。
以下にライブラリ等のバージョンを記載します。
(pip freeze > requirements.txt)
abstract_singleton==1.0.1
aiofiles==23.1.0
aiohttp==3.8.4
aiosignal==1.3.1
alabaster==0.7.12
altgraph==0.17.2
anyio==3.7.0
appdirs==1.4.4
arabic-reshaper==2.1.3
asgiref==3.5.2
asn1crypto==1.5.1
astroid==2.11.7
async-generator==1.10
async-timeout==4.0.2
asynctest==0.13.0
attrs==22.1.0
auto-py-to-exe==2.22.0
auto_gpt_plugin_template @ git+https://github.com/Significant-Gravitas/Auto-GPT-Plugin-Template@7612a14c629dc64ad870eee4d05850d60e1dd9ce
autobahn==22.7.1
autoflake==2.2.0
Automat==22.10.0
Babel==2.10.3
backcall==0.2.0
beautifulsoup4==4.12.2
black==23.3.0
bleach==5.0.1
blis==0.7.9
boltons==23.0.0
bottle==0.12.23
bottle-websocket==0.2.9
Brotli==1.0.9
cachetools==5.2.0
catalogue==2.0.8
certifi==2022.6.15
cffi==1.15.1
cfgv==3.3.1
channels==4.0.0
channels-redis==4.0.0
chardet==5.0.0
charset-normalizer==3.1.0
chromedriver-autoinstaller==0.4.1
chromedriver-binary==105.0.5195.19.0
click==8.1.3
cloudpickle==2.1.0
colorama==0.4.6
confection==0.0.4
constantly==15.1.0
coverage==7.2.7
cryptography==37.0.4
cssselect==1.2.0
cssselect2==0.6.0
cymem==2.0.7
Cython==0.29.32
daphne==4.0.0
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.13
dill==0.3.5.1
distlib==0.3.6
distro==1.8.0
Django==4.1
django-allauth==0.51.0
django-crispy-forms==1.14.0
django-filter==22.1
django-login-required-middleware==0.8.0
django-widget-tweaks==1.4.12
dnspython==2.3.0
docker==6.1.3
docutils==0.19
duckduckgo-search==3.0.2
Eel==0.14.0
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
et-xmlfile==1.1.0
exceptiongroup==1.1.1
execnet==1.9.0
filelock==3.8.0
flake8==6.0.0
frozenlist==1.3.3
funcsigs==1.0.2
future==0.18.2
gevent==21.12.0
gevent-websocket==0.10.1
ghp-import==2.1.0
gitdb==4.0.10
GitPython==3.1.31
google-api-core==2.11.0
google-api-python-client==2.86.0
google-auth==2.18.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.59.0
greenlet==1.1.2
gTTS==2.3.1
h11==0.13.0
h2==4.1.0
hpack==4.0.0
html5lib==1.1
httpcore==0.17.2
httplib2==0.22.0
httpx==0.24.1
hyperframe==6.0.1
hyperlink==21.0.0
identify==2.5.24
idna==3.3
ImageHash==4.3.1
incremental==22.10.0
iniconfig==2.0.0
interchange==2021.0.4
ipaddress==1.0.23
isort==5.10.1
Jinja2==3.1.2
jsonschema==4.17.3
Kivy==2.1.0
kivy-deps.angle==0.3.2
kivy-deps.glew==0.3.1
kivy-deps.gstreamer==0.3.3
kivy-deps.sdl2==0.4.5
Kivy-Garden==0.1.5
langcodes==3.3.0
lazy-object-proxy==1.7.1
loguru==0.7.0
lxml==4.9.2
Markdown==3.3.7
MarkupSafe==2.1.3
mccabe==0.7.0
mergedeep==1.3.4
mkdocs==1.4.3
monotonic==1.6
MouseInfo==0.1.3
msgpack==1.0.4
mss==9.0.1
multidict==6.0.4
murmurhash==1.0.9
mypy==1.4.1
mypy-extensions==1.0.0
natsort==8.3.0
neobolt==1.7.17
neotime==1.7.4
nodeenv==1.8.0
Nuitka==1.0.4
numpy==1.23.2
oauthlib==3.2.0
openai==0.27.2
openapi-python-client==0.13.4
opencv-python==4.6.0.66
openpyxl==3.0.10
orjson==3.8.10
oscrypto==1.3.0
outcome==1.2.0
packaging==23.1
pandas==1.4.3
pansi==2020.7.3
pathspec==0.11.1
pathy==0.10.1
pefile==2022.5.30
phonenumbers==8.13.16
Pillow==9.2.0
pinecone-client==2.2.1
pip-review==1.1.1
platformdirs==2.5.2
playsound==1.2.2
pluggy==1.0.0
pre-commit==3.3.3
preshed==3.0.8
prompt-toolkit==3.0.39
protobuf==4.23.0
py-cpuinfo==9.0.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
PyAudio==0.2.13
PyAutoGUI==0.9.53
pycodestyle==2.10.0
pycparser==2.21
pydantic==1.10.9
pyflakes==3.0.1
pygame==2.1.2
PyGetWindow==0.0.9
Pygments==2.3.1
pyHanko==0.13.2
pyhanko-certvalidator==0.19.5
pyinstaller==5.3
pyinstaller-hooks-contrib==2022.8
PyJWT==2.4.0
pylatexenc==2.10
pylint==2.14.5
pymdown-extensions==10.0.1
PyMsgBox==1.0.9
PyMySQL==1.0.2
pyOpenSSL==22.0.0
pyotp==2.7.0
pyparsing==3.0.9
PyPDF2==2.10.2
PyPDF3==1.0.6
pyperclip==1.8.2
pypiwin32==223
PyRect==0.2.0
pyrsistent==0.19.3
PyScreeze==0.1.28
PySocks==1.7.1
pytest==7.3.2
pytest-asyncio==0.21.0
pytest-benchmark==4.0.0
pytest-cov==4.1.0
pytest-integration==0.2.3
pytest-mock==3.11.1
pytest-recording==0.12.2
pytest-xdist==3.3.1
python-bidi==0.4.2
python-dateutil==2.8.2
python-docx==0.8.11
python-dotenv==1.0.0
python3-openid==3.2.0
pytweening==1.0.4
pytz==2022.2.1
pytz-deprecation-shim==0.1.0.post0
PyWavelets==1.4.1
pywin32==304
pywin32-ctypes==0.2.0
PyYAML==6.0
pyyaml_env_tag==0.1
qrcode==7.3.1
readability-lxml==0.8.1
redis==4.3.4
regex==2023.6.3
reportlab==3.6.11
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
scipy==1.9.1
screeninfo==0.8.1
selenium==4.1.4
service-identity==21.1.0
shellingham==1.5.0.post1
six==1.16.0
slackweb==1.0.5
smart-open==6.3.0
smmap==5.0.0
sniffio==1.2.0
socksio==1.0.0
sortedcontainers==2.4.0
soupsieve==2.4.1
spacy==3.5.4
spacy-legacy==3.0.12
spacy-loggers==1.0.4
sqlparse==0.4.2
srsly==2.4.6
svglib==1.4.1
thinc==8.1.10
tiktoken==0.3.3
tinycss2==1.1.1
tomli==2.0.1
tomlkit==0.11.4
toolz==0.12.0
tqdm==4.65.0
trio==0.21.0
trio-websocket==0.9.2
tweepy==4.14.0
Twisted==22.10.0
twisted-iocpsupport==1.0.2
txaio==22.2.1
typer==0.7.0
types-beautifulsoup4==4.12.0.5
types-colorama==0.4.15.11
types-html5lib==1.1.11.14
types-Markdown==3.4.2.9
types-Pillow==9.5.0.6
typing_extensions==4.4.0
tzdata==2022.2
tzlocal==4.2
uritemplate==4.1.1
uritools==4.0.0
urllib3==1.26.12
urllib3-secure-extra==0.1.0
vcrpy @ git+https://github.com/Significant-Gravitas/vcrpy.git@2f6fa05ae3518b1c0e92e63c3d12ecf5cf82cd48
virtualenv==20.17.1
wasabi==0.10.1
watchdog==3.0.0
wcwidth==0.2.5
webdriver-manager==3.8.6
webencodings==0.5.1
websocket-client==1.4.2
wget==3.2
whichcraft==0.6.1
win32-setctime==1.1.0
wrapt==1.14.1
wsproto==1.1.0
xhtml2pdf==0.2.8
xlrd==2.0.1
XlsxWriter==3.1.2
yarl==1.9.2
zope.event==4.5.0
zope.interface==5.4.0