19日に更新してた

アフィリエイトはないよ

chrome driver で chrome plugin や cookie を使う (python,win10)

selenium から chrome driver を使っているときに「python でログイン書くのもどうかなぁ、個人用だし」とか「読み込みスピード上げる chrome plugin を使いたいなぁ」などという場合がありまして、その時に

from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument(r'--user-data-dir=C:\Users\username\chrome\profile')
driver_path = r'C:\Users\Username\chromedriver.exe'
driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)

profile のディレクトリを作っておいて、chrome driver を起動して目的サイトのログインをしたり、plugin をインストールして立ち上げたウインドウの chrome で有効化して、その profile を指定して chrome driver を起動することで、chrome を手動で操作したときのように cookie や plugin を使って動作するようにしています。

まだ、本格的にはやっていないのですが、読み込み速度上げるために画像や広告の読み込みを止めるには、Text Mode を使うのが面倒が少なさそうでいいかなと思っております。
chrome.google.com