0
我正在嘗試編寫一個簡單的程序來反覆在YouTube上打開一個3分鐘的視頻,並在特定數量的頁面關閉每個瀏覽器後再重新開始 但它只運行一旦..請指點繼續在Python中播放YouTube剪輯
#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()
感謝您的回覆。此計劃的目的是儘可能多地增加此剪輯的視圖 – SkyW3lker