Python 指定区域截图

先上代码

from pyautogui import screenshot
import time
from PIL import ImageGrab
# Grab Screenshot of Screen
def grab_screenshot():
    shot = screenshot()
    shot.save('my_screenshot.png')
# Grab Screenshot of Specific Area
def grab_screenshot_area():
    area = (0, 0, 500, 500)   # 这里是设置截图范围的区域
    shot = ImageGrab.grab(area)
    shot.save('my_screenshot_area.png')
# Grab Screenshot with Delay
def grab_screenshot_delay():
    time.sleep(5)
    shot = screenshot()
    shot.save('my_screenshot_delay.png')

使用此脚本,你可以直接截屏或截取特定区域的屏幕截图。
可以加载在一些抢购的脚本中,把秒杀产品抢到手后,进行截图,然后继续抢下一个

你可能感兴趣的:(Python脚本工具,python)