Bootstrap

【自动化】如何自动化识别验证码进行输入登陆

import pyautogui
import time
from ddddocr import DdddOcr
ocr = DdddOcr()
from DrissionPage._pages.chromium_page import ChromiumPage
page = ChromiumPage()
page.get('https://zyjs.heb12333.cn')

page.ele('x://div[@class="el-input el-input--mini el-input--prefix"]/input').input("13*******17")
page.ele('x://div[@class="el-input el-input--mini el-input--prefix el-input--suffix"]/input').input("L****@")

imgbytes=page.ele('x://div[@class="fr captcha"]/img').src()
yzm = ocr.classification(imgbytes)
print(yzm)


page.ele('x://*[@id="__layout"]/div/div[3]/div[2]/div[1]/div[3]/div[1]/div/div[2]/form/div[3]/div/div[1]/input').input(yzm)
time.sleep(3)
page.ele('x://button[@class="el-button login-btn el-button--primary el-button--mini"]').click()
time.sleep(1)
page.get('https://webzyjs.heb12333.cn/index.html#/v_courseDetails?courseId=NeS75S1e49zyllShwmP5G&trainplanId=33a530966b504e65a9780bc0eabc9ee3&platformId=251&fromPage=selected')
time.sleep(2)


for i in range(1,8):
    page.get(f'https://webzyjs.heb12333.cn/index.html#/v_video?platformId=251&trainplanId=33a530966b504e65a9780bc0eabc9ee3&courseId=HYJaaPPoYCglqaytKMECN&sectionId=HYJaaPPoYCglqaytKMECN1-{i}')
    time.sleep(10)
    pyautogui.click(675, 465, button='left')
    if i == 1:
        times = 2
        ztimes = times * 60
    if i == 2:
        times = 10
        ztimes = times * 60
    if i == 3:
        times = 12
        ztimes = times * 60
    if i == 4:
        times = 5
        ztimes = times * 60
    if i == 5:
        times = 29
        ztimes = times * 60
    if i == 6:
        times = 25
        ztimes = times * 60
    if i == 7:
        times = 23
        ztimes = times * 60
    time.sleep(ztimes)
    i += 1
    if i > 8:
        break
;