#ページ全体のスクリーンショット
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
# ブラウザーを起動
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome('/Desktop/selenium/chromedriver', options=options)
driver.get("https://www.yahoo.co.jp/")
w = driver.execute_script('return document.body.scrollWidth')
h = driver.execute_script('return document.body.scrollHeight')
driver.set_window_size(w, h)
driver.save_screenshot('{保存先path}')
# ブラウザを終了する。
driver.close()
setup
$ pip install selenium
$ brew install chromedriver
$ pip install webdriver_manager