[英]Take screenshot of webelement in Selenium Python and save file
[英]Take Screenshot on Windows and save it?
我想使用python截圖(僅Windows)並保存它! 我正在使用pyscreenshot庫和PIL
import numpy as np
import matplotlib.pyplot as plt
from PIL import ImageGrab
import pyscreenshot as ImageGrab
img = ImageGrab.grab()
plt.imshow(img, cmap='gray', interpolation='bicubic')
plt.save('img.png')
試試這個代碼:
import pyscreenshot as ImageGrab
# fullscreen
im=ImageGrab.grab()
im.show()
# part of the screen
im=ImageGrab.grab(bbox=(10,10,500,500))
im.show()
# to file
ImageGrab.grab_to_file('im.png')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.