1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Selenium入門

Last updated at Posted at 2022-06-21

python環境構築はこちら

レスポンス取得プラグイン

pipを最新化

~/temporary/venv/bin/python -m pip install --upgrade pip
pip install selenium

ライブラリ一覧確認

pip list
temporary % pip list
Package          Version
---------------- ---------
async-generator  1.10
attrs            21.4.0
certifi          2022.6.15
cffi             1.15.0
cryptography     37.0.2
h11              0.13.0
idna             3.3
outcome          1.2.0
pip              22.1.2
pycparser        2.21
pyOpenSSL        22.0.0
PySocks          1.7.1
selenium         4.2.0
setuptools       58.1.0
sniffio          1.2.0
sortedcontainers 2.4.0
trio             0.21.0
trio-websocket   0.9.2
urllib3          1.26.9
wsproto          1.1.0

Chromeのバージョンを確認
... 右上の3点リーダ>ヘルプ>Chrome について
バージョン: 102.0.5005.115(Official Build) (x86_64)
ダウンロードページで確認したバージョンのものをダウンロード

If you are using Chrome version 102, please download ChromeDriver 102.0.5005.61

mkdir web-driver

cd web-driver

mv ~/Downloads/chromedriver

mkdir source

echo "" >> test.py

open -a textedit ./test.py

Webドライバのパス指定は、ルートからの絶対パスのみ、相対ぱすは使えない
from selenium import webdriver
driver = webdriver.Chrome("ルート〜/temporary/web-driver/chromedriver")
driver.get("https://google.co.jp")

python source/test.py

"chromedriver"は開発元を検証できないため開けません

環境設定>プライバシーとセキュリティ>一般 このまま許可を選択

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?