欢迎光临散文网 会员登陆 & 注册

Python解决观看继续教育视频的烦恼!

2022-12-26 21:12 作者:珍宝杂货铺  | 我要投稿

       对于评职称的人来说,需要在--广东人才继续教育网--观看视频来完成专业科目,选修科目的课时,这是一项重复且耗时间的事情!

广东人才继续教育网

       对于手工一遍一遍地重复点击视频,累死人不说,最重要的是浪费时间,怎么能忍重复3次以上的工作,必须利用程序自动化。这里引进Python--autogui  使用一段程序代码实现自动观看视频。

下面为具体代码:

'''实现继续教育做题'''
import pyautogui
import time

def click_Exit():
   left_w, top_w, width_w, height_w = pyautogui.locateOnScreen('a02.png')
   center_w = pyautogui.center((left_w, top_w, width_w, height_w))
   time.sleep(0.5)  ##等待时间0.5秒
   pyautogui.click(center_w) #单击-(退出播放02)
   print('点击学习进度成功')

def click_Learning():
    left2, top2, width2, height2 = pyautogui.locateOnScreen('a03.png')
    center2 = pyautogui.center((left2, top2, width2, height2))
    pyautogui.click(center2)#单击-(继续学习03)
    print('点击继续学习')

def click_View():
   left1, top1, width1, height1 = pyautogui.locateOnScreen('a04.png')
   center1 = pyautogui.center((left1, top1, width1, height1))
   pyautogui.click(center1)  # 单击-(开始观看)
   print('点击开始观看')

def click_Play():
   left_s, top_s, width_s, height_s = pyautogui.locateOnScreen('a05.png')
   center_s = pyautogui.center((left_s, top_s, width_s, height_s))
   time.sleep(0.5)  ##等待时间0.5秒
   pyautogui.click(center_s) #单击-(点击播放)
   print('点击播放')


while True:
   if pyautogui.locateCenterOnScreen('a01.png') is None: # 没有出现结束的图
       print("未找到匹配图片,2秒后重试")
       time.sleep(2)  # 等待时间2秒
   else: # 学习进度完成
       print("找到完成图片!")
       click_Exit()#点击退出播放
       print("点击~退出播放~")
       time.sleep(2) #等待时间2秒
       click_Learning()#点击继续学习
       print("点击~继续学习~")
       time.sleep(0.5)  # 等待时间0.5秒

       #判断视频播放是否结束的循环
       while True:
           pyautogui.scroll(-300)  # 鼠标滚轮往下200
           time.sleep(2)  # 等待时间2秒
           if pyautogui.locateCenterOnScreen('a04.png') is None:  # 没有出现开始观看的图
               print("未找到开始观看,2秒后重试~")
               pyautogui.scroll(-100)
               time.sleep(2)
           else:  # 出现出现课间习题
               click_View()#单击-(开始观看)
               print("点击~开始观看~")
               time.sleep(3)  # 等待时间3秒
               click_Play()#单击-(点击播放)
               break


注释:a01.png;a02.png;a03.png;a04.png;a05.png为需要鼠标点击位置的图片。

  Python--autogui 是一个强大的自动操作库,我使用autogui实现在继续教育网站观看专业课,选修课和公需课,特别是公需课,在观看视频中是需要做题提交答案,这时候需要引进random配合autogui 自动观看视频并做题。


Python解决观看继续教育视频的烦恼!的评论 (共 条)

分享到微博请遵守国家法律