大数跨境
0
0

用Python写的一段可以自动观看学习视频的代码

用Python写的一段可以自动观看学习视频的代码 科技码源
2023-10-23
1
导读:今天给大家分享一款全自动视频学习软件,软件运行后,会自动完成播放列表中所有视频的观看。该软件利用python中的pyautogui库编写,功能灵活多变。该软件已经过近10小时的调试和运行,基本稳定。现

Python编程界面

今天给大家分享一款全自动视频学习软件,软件运行后,会自动完成播放列表中所有视频的观看。该软件利用python中的pyautogui库编写,功能灵活多变。该软件已经过近10小时的调试和运行,基本稳定。现将代码作以分享。




Python代码


import pyautoguiimport timeimport cv2# 按 Shift+F10 执行或将其替换为您的代码。# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。import pyperclipdef netStudy():    # 3.获取课程目录图片    kechengmululocation = pyautogui.locateOnScreen('autoclick/kechengmulu.png', confidence=0.8)    # 如果找到了播放按钮    if not (kechengmululocation is None):        # 找到播放按钮的位置,鼠标左键单击        pyautogui.press('F12')    time.sleep(0.5)    Consolelocation = pyautogui.locateOnScreen('autoclick/Console.png', confidence=0.8)    # 如果找到了播放按钮    if Consolelocation is not None:        # 找到播放按钮的位置,鼠标左键单击        clickpoint = pyautogui.center(Consolelocation)        pyautogui.click(clickpoint[0], clickpoint[1] + 500, button='left')        # time.sleep(0.1)        pyautogui.hotkey("ctrl", "v")        pyautogui.press('Enter')
# 5.获取关闭图片 closelocation = pyautogui.locateOnScreen('autoclick/close.png', confidence=0.8) # 如果找到了播放按钮 if closelocation is not None and kechengmululocation is not None: # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(closelocation) pyautogui.click(clickpoint[0], clickpoint[1], button='left') kechengmululocation = None time.sleep(1) # 6.获取离开图片 leavelocation = pyautogui.locateOnScreen('autoclick/leave.png', confidence=0.8) # 如果找到了播放按钮 if not (leavelocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(leavelocation) pyautogui.click(clickpoint[0], clickpoint[1], button='left') # 程序休眠0.8秒钟 time.sleep(0.3)
def autoStudy(): # 死循环,每隔5秒去查一次播放状态。这个时间可以自己调整
f = open("code.txt", encoding=' utf - 8') text = f.read() pyperclip.copy(text) f.close() while 1: m,n = pyautogui.size() # 2.获取刷新按钮图片 shuaxinlocation = pyautogui.locateOnScreen('autoclick/shuaxin.png', confidence=0.8) # 如果找到了播放按钮 if not (shuaxinlocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(shuaxinlocation) pyautogui.click(clickpoint[0], clickpoint[1], button='left') time.sleep(0.3) # 找继续学习按钮 percentagelocation = pyautogui.locateOnScreen('autoclick/percentage.png', confidence=0.8) # 如果找到了播放按钮 if not (percentagelocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(percentagelocation) pyautogui.click(clickpoint[0] + 150, clickpoint[1], button='left') time.sleep(0.3) netStudy() else: pyautogui.scroll(-600, m / 2, n / 2) time.sleep(0.3) percentagelocation = pyautogui.locateOnScreen('autoclick/percentage.png', confidence=0.8) # 如果找到了播放按钮 if not (percentagelocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(percentagelocation) pyautogui.click(clickpoint[0] + 150, clickpoint[1], button='left') # 程序休眠0.8秒钟 time.sleep(0.3) netStudy() else: pyautogui.click(m / 2+500, n / 2, button='left')
else: pyautogui.scroll(600, m / 2, n / 2) time.sleep(0.3) shuaxinlocation = pyautogui.locateOnScreen('autoclick/shuaxin.png', confidence=0.8) # 如果找到了播放按钮 if not (shuaxinlocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(shuaxinlocation) pyautogui.click(clickpoint[0], clickpoint[1], button='left') # 找继续学习按钮 percentagelocation = pyautogui.locateOnScreen('autoclick/percentage.png', confidence=0.8) # 如果找到了播放按钮 if not (percentagelocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(percentagelocation) pyautogui.click(clickpoint[0] + 150, clickpoint[1], button='left') netStudy() else: pyautogui.scroll(-600,m / 2, n / 2) time.sleep(0.3) percentagelocation = pyautogui.locateOnScreen('autoclick/percentage.png', confidence=0.8) # 如果找到了播放按钮 if not (percentagelocation is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(percentagelocation) pyautogui.click(clickpoint[0] + 150, clickpoint[1], button='left') netStudy()
# 1.查找刷新总按钮的位置 shuaxinAll = pyautogui.locateOnScreen('autoclick/shuaxinAll.png', confidence=0.8) # shuaxinAllcenter = pyautogui.center(shuaxinAll) # # 鼠标移动到播放器上,显示播放按钮 # pyautogui.moveTo(shuaxinAll.x + 100, shuaxinAll.y + 100, duration=0.25) if not (shuaxinAll is None): # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(shuaxinAll) pyautogui.click(clickpoint[0], clickpoint[1], button='left') time.sleep(0.3) startstudylocation = pyautogui.locateOnScreen('autoclick/startstudy.png', confidence=0.8) # 如果找到了播放按钮 if startstudylocation is not None: # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(startstudylocation) pyautogui.click(clickpoint[0]+80, clickpoint[1]-10, button='left') time.sleep(1) else: pyautogui.click(m / 2, n / 2, button='left') pyautogui.scroll(-1000) time.sleep(0.3) startstudylocation = pyautogui.locateOnScreen('autoclick/startstudy.png', confidence=0.8) # 如果找到了播放按钮 if startstudylocation is not None: # 找到播放按钮的位置,鼠标左键单击 clickpoint = pyautogui.center(startstudylocation) pyautogui.click(clickpoint[0] + 80, clickpoint[1] - 10, button='left') time.sleep(1) kechengmululocation = pyautogui.locateOnScreen('autoclick/kechengmulu.png', confidence=0.8) # 如果找到了播放按钮 if not (kechengmululocation is None): netStudy()
# 按间距中的绿色按钮以运行脚本。if __name__ == '__main__': autoStudy()


code代码



function skip(){  let video=document.getElementsByTagName('video')for(let i=0;i<video.length;i++){    video[i].currentTime=video[i].duration  }}setInterval(skip,200)






编程不易,且用且珍惜!

感谢观看

2023.10.23



【声明】内容源于网络
0
0
科技码源
科技码源
内容 201
粉丝 0
科技码源 科技码源
总阅读97
粉丝0
内容201