PythonでのSeleniumのChromedriverの件です。
昨日までサクサク動いていたプログラムが急に動かなくなったぞ?
えーと、 「selenium this version of chromedriver only supports~」
そうか、またChromeのバージョンアップか。 ということで、ドライバーをアップデートするわけですが、そのやり方については以前触れました。
でも、いい加減面倒になってくるんですね。 自動でやってくれないかなー、と。
そうしたら、同じように考える人はいるようです。 毎回プログラムの起動時に、対応しているChromedriverかどうかチェックしてくれて、対応していなかったらアップデートしておいてくれるライブラリがありました。
webdriver_manager
というものですが、普通にpipでインストールできます。
pip install webdriver-manager
あとは、ブラウザを立ち上げるプログラムを少し書き換えるだけです。
from webdriver_manager.chrome import ChromeDriverManager
を冒頭に追加して、
driver = webdriver.Chrome()
だったところを
driver = webdriver.Chrome(ChromeDriverManager().install())
に変えるだけです。 これで手動アップデートとはおさらば。 一つ難点があるとすれば、ブラウザが立ち上がるたびに、
[WDM] – Current google-chrome version is 89.0.4389 [WDM] – Get LATEST driver version for 89.0.4389 [WDM] – Driver [/Users/*****/drivers/chromedriver/mac64/89.0.4389.87/chromedriver] found in cache
といった表示がされるので、ちょっとウザいということくらいでしょうか。
Selenium本
Hands-On Web Scraping with Python Perform advanced scraping operations using various Python librarie
4,304円(税込)【送料込】
楽天Kobo電子書籍ストア
<p><b>Collect and scrape different complexities of data from the modern Web using the latest tools,
Selenium with Python - A Beginner’s Guide Get started with Selenium using Python as a programming la
2,598円(税込)【送料込】
楽天Kobo電子書籍ストア
<p>Selenium is the most popular open source test automation tool available in the market. In the las
Selenium自?化??完全指南:基于Python【電子書籍】[ ?卓 ]
2,242円(税込)【送料込】
楽天Kobo電子書籍ストア
<p>本?共有19章。第1〜10章介?Selenium IDE、Selenium WebDriver、Selenium Grid、Appium等工具的?用。第11〜16章介?自?化????的??及模式
Python??WebUI自?化????ーーSelenium3/4+unittest/Pytest+GitLab+Jenkins【電子書籍】[ Storm ]
2,265円(税込)【送料込】
楽天Kobo電子書籍ストア
<p>本?主要介?如何基于Python使用Selenium、unittest、Pytest、GitLab、Jenkins等工具??Web UI自?化??,以?助?者提升??水平。本?第1章?要介?自?
Selenium with Python - A Beginner’s Guide【電子書籍】[ Pallavi R Sharma ]
1,100円(税込)【送料込】
楽天Kobo電子書籍ストア
<p>Selenium is the most popular open-source test automation tool available in the market. In the las