我正在尝试编写一个简单的程序来一遍又一遍地在 youtube 中打开一个 3 分钟的视频,并在特定数量的页面后关闭每个浏览器然后重新开始但它只运行一次.. 请建议
#Keep playing a youtube clip
import time , webbrowser , os
total_breaks = -1
start=0
def Play():
try:
while start != total_breaks:
print("The {} Play of WaKra Movie started at ".format(start+1),time.ctime())
with webbrowser.open("https://www.youtube.com/watch?v=XXXXXXXXXX") as play:
time.sleep(5) #*60*60)
global start
start = start + 1
#time.sleep(5)
if start % 5 == 0: #every 5 pages close all browsers
os.popen('TASKKILL /IM iexplore.exe /f')
os.popen('TASKKILL /IM firefox.exe /f ')
os.popen('TASKKILL /IM chrome.exe /f ')
except:
print ("Some Browsers were not found")
print("Program terminated at",time.ctime())
Play()