31
29

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でScreenShot ( Python編 )

Posted at

動機

  • Recommendでこんな記事 を見つけた
    • 結構大変そうだったから自分も同じことやってたので書いてみようと.
  • インフルエンザニートしてて暇だった.

目的

  • Selenium Web Driverを使ってBrowserのScreenShotを取得する.
    • 操作等は一切なし.それはまた別途説明すればええし.

実装

とりあえず同一階層上に"screen.png"というファイルを作成してそこにScreenShotを保存するだけのスクリプト.

screenshot.py
import os
from selenium import webdriver

# URL & File Name
URL = "https://www.google.com"
FILENAME = os.path.join(os.path.dirname(os.path.abspath(__file__)), "screen.png")

# Open Web Browser & Resize 720P
driver = webdriver.Firefox()
driver.set_window_size(1280, 720) 
driver.get(URL)

# Get Screen Shot
driver.save_screenshot(FILENAME)

# Close Web Browser
driver.quit()

動作確認はしてない.多分動くと思う.知らんけど.

結論

  • インフルエンザニート,3日目に突入すると結構元気になるから逆に辛い
31
29
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
31
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?