8
9

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 5 years have passed since last update.

Seleniumを使ってPythonでブラウザ操作

Posted at

Windows10、Python3.6.3での使い方をまとめてみました。
Linux、macOSは、機会があったら追加します。

PythonのSeleniumライブラリインストール

pip install selenium

各ブラウザのSelenium用ドライバの入手と使い方

使いやすい

使用例
from selenium import webdriver
browser = webdriver.Chrome(executable_path='C:\Work\Selenium\chromedriver.exe')
browser.get(https://www.google.co.jp/)
使用例
from selenium import webdriver
browser = webdriver.Edge(executable_path='C:\Work\Selenium\MicrosoftWebDriver.exe')
browser.get('https://www.bing.com/')
使用例
from selenium import webdriver
browser = webdriver.PhantomJS(executable_path='C:\Work\Selenium\phantomjs.exe')
browser.get('http://seleniumhq.org/')
browser.save_screenshot('C:\Work\screenshot.png')

設定が面倒

動かせなかった。。。

Firefoxは奥が深そうなので割愛しました。

8
9
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
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?