我试图拍摄我打开的网页的快照,但我需要延迟代码的第二部分,以便程序有时间打开页面
这是代码
import os
import sys
import time
import Image
import ImageGrab
import webbrowser
webbrowser.open_new(input("URL: "))
#Need to delay here
SaveDirectory=r'C:\Documents and Settings\User\My Documents\My Pictures'
ImageEditorPath=r'C:\WINDOWS\system32\mspaint.exe'
img=ImageGrab.grab()
box = (100, 100, 400, 400)
region = img.crop(box)
saveas=os.path.join(SaveDirectory,'ScreenShot_'+'.png')
img.save(saveas)
editorstring='""%s" "%s"'% (ImageEditorPath,saveas)
os.system(editorstring)