Python 3.10(←当初12と誤記していたものを訂正) と Selenium 4.15.2 で Firefox 115.4.0_ESR のスクレイピングをするコードを書いています。
「最近のSeleniumのバージョンには SeleiumManager が付いていて、WebDriver(FirefoxなのでGeckoDriver)の手動更新は不要」との記述をWebで見つけて、下記のようにドライバーを読み込もうとしています。
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
デバッグすると次のようなエラーが出ます。
selenium.common.exceptions.WebDriverException: Message: Unable to obtain working Selenium Manager binary; C:\Users\(中略)\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe
確かにそのフォルダはあっても exe ファイルはありません。
そこで、Seleniumの公式サイトで SeleniumManager の実行ファイルの在処を
下記から辿ることができたので、ダウンロードして上記のフォルダに置きました
https://www.selenium.dev/documentation/selenium_manager/#getting-selenium-manager
すると(一歩進んで)今度はデバッグで「バージョンが合わない」「実行できない」
とエラーが出ます。エラーメッセージは;
エラー #1:
OSError: [WinError 216] このバージョンの %1 は、実行中の Windows のバージョンと互換性がありません。
エラー #2:
selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: C:\Users\(中略)\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser firefox --output json
コンピューター のシステム情報を確認してから、ソフトウェアの発行元に問い合わせてください。
結局、WebDriver Manager を使う方法で所望の動作はするようになったのですが、SeleniumManagerの機能を使えていないのがいまいちだと感じています。
解決策、トライする方向性、参照すべきサイトなど、ご存じの方は教えていただけませんでしょうか。