python take screenshot of website code example

Example 1: how to take screenshots with selenium webdriver python

from selenium import webdriver
from time import sleep

driver = webdriver.Firefox()
driver.get('https://www.python.org')
sleep(1)

driver.get_screenshot_as_file("screenshot.png")
driver.quit()
print("end...")

Example 2: screenshot in python

import pyautogui


class gng() :
    myScreenshot = pyautogui.screenshot()
    myScreenshot.save('C:\File\Code\save.png')


gng()

Example 3: python windows take screenshot pil

import PIL.ImageGrab

im = PIL.ImageGrab.grab()
im.show()

Example 4: take screenshot of website python

Mac: webkit2png 
Linux+KDE: khtml2png. 
Windows: webscreenshot