LoginSignup
1
2

More than 5 years have passed since last update.

SeleniumでHeadless Chromeを使ってみよう(winodows編)

Last updated at Posted at 2019-03-27

鬱陶しい画面にはHeadless Chrome

業務でSeleniumを使うことがありますが、使い始めて一か月ほど画面を開かずに使える方法を全く知りませんでした。
お恥ずかしい話ですが、webdriverのスクリーンサイズを最小にして使っていました。

optionsを使って設定

Seleniumはモジュールが結構多いので、ほかにも色々試せそうです。

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

url = "https://www.google.com/"

options = Options()
options.add_argument("--headless")

driver = webdriver.Chrome("exeファイルのあるディレクトリ",chrome_options=options)

driver.get(url)
driver.save_screenshot("google.png")
driver.close()
1
2
1

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