プログラミンGOO

プログラミングナレッジ、ワードプレス、広告収入等について、気づき・備忘録を残していきます。

pythonにSelenium導入備忘録

■必要なもの

Firefoxウェブドライバー:Firefox公式ページ
Python:Python公式ページ
selenium:Pythonのpip
Powershell最新版

■パワーシェルの実行権限
win+r =>powershell
set-executionpolicy remotesigned
Y
上矢印キーを2回押してset-executionpolicy remotesigned
が表示されたら、get-executionpolicyに修正
Enter
remotesignedと表示されればOK
■Pythonのインストール

https://www.python.org/から。
適したバージョンのexecutable installerをダウンロード
Customize installationを選択
pip、Add Python to environment variables(環境変数にパスを通す)を選択

※デフォルトでインストールした場合、インストールされる先は以下
C:\Users\under\AppData\Local\Programs

・バージョン確認

python-V
■Seleniumのインストール

powershellで以下を入力

pip install selenium

Pythonのフォルダの下位層にインストールされる

■Firefoxwebdriver(geckodriver)のインストール

以下のサイトからwin版のドライバをダウンロード
https://github.com/mozilla/geckodriver/releases

Pythonフォルダ内にドライバ(geckodriver.exe)を格納
Python\python**-**