個人的によく使うことをメモしておきます。使うんだけど忘れちゃうので。
思いついたらどんどん加筆していきます。
仮想環境をbaseに切り替えるコマンド
$ conda activate
(base) $
参考)Conda コマンド
https://www.python.jp/install/anaconda/conda.html
Google ChromeとChromeDriverのバージョン不一致のとき
ChromeDriverのinstall
$ pip3 install chromedriver-binary==79.0.3945.36.0
chromeのバージョンのひとつ下くらいのDriverのバーションをインストールする
参考)【Python/Selenium】ChromeDriverバージョンエラー対処法
https://yuki.world/python-chrome-driver-version-error/
chromedriverリリース履歴
https://pypi.org/project/chromedriver-binary/#history
Seleniumのバージョン確認
$ pip show selenium
Seleniumのバージョン最新版にアップデート
$ pip install -U selenium
Google ChromeとChromeDriverのバージョン不一致のとき 更新版
Selenium 4.6から、Selenium自体にChromeDriver自動更新機能「Selenium Manager」が搭載されたことで、このシンプルな記述だけで済むようなりました。
from selenium import webdriver
driver = webdriver.Chrome()
参考)【Selenium】ChromeDriver自動更新で楽する方法【Python】
https://yuki.world/python-selenium-chromedriver-auto-update/
seleniumのoption
headlessとか
from selenium import webdriver
options = webdriver.ChromeOptions()
# 必須
options.add_argument('--headless')
options.add_argument('--disable-gpu')
# エラーの許容
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-running-insecure-content')
options.add_argument('--disable-web-security')
参考)headless chromeをPythonのseleniumから動かして引数を考えた (Ubuntu 16.04)
https://vaaaaaanquish.hatenablog.com/entry/2017/06/06/194546