0
2

More than 1 year has passed since last update.

seleniumチートシート(Windows&Python編)

Posted at

分類:Python3,Windows10,クロム
日付:2021/11/04

seleniumの使い方を毎回忘れるのでチートシートにしました

環境構築

①クロムのバージョンチェック

メニュー右上の︙アイコンをクリック、→ ヘルプ → googleクロムについて を選ぶ

c1.JPG

c2.JPG

②ダウンロードのページ

  https://chromedriver.chromium.org/downloads

c3.JPG

確認したバージョンに合わせてリンク先を選択

③Windows10はchromedriver_win32.zipをダウンロード

c4.JPG

④zipを解凍してできた chromedriver.exe をc:\にコピー

このあとPythonのコードで

test.py
driver = webdriver.Chrome("c:\chromedriver")

 として使うので c:\ に解凍していますが、ほかのフォルダで使うときは、コードとフォルダ名を合わせればOKです

⑤Python側でseleniumライブラリをインストール

 pip install selenium

⑥動作テストはこんな感じ

test.py
    from selenium import webdriver
    driver = webdriver.Chrome("c:\chromedriver")
    driver.get("https://yahoo.com")
    driver.close()
    driver.quit()

yahooが開いて閉じればインストール成功!

0
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
0
2