from selenium.webdriver.common.by import By from selenium import webdriver from time import sleep import ddddocr """ 登录 输入手机号 密码登录 识别验证码 登录 """ driver=webdriver.Chrome() driver.get("XXXXXXXXXX") # 登录 driver.find_element(By.XPATH,"/html/body/div[1]/div/div[2]/ul/li[1]/a").click() sleep(3) # 账号 driver.find_element(By.XPATH,"/html/body/div[4]/div/div[1]/div[2]/form/div[1]/span[2]/input").send_keys("") sleep(3) # 密码 driver.find_element(By.XPATH,"/html/body/div[4]/div/div[1]/div[2]/form/div[2]/span[2]/input").send_keys("") sleep(3) # 定位验证码图片 driver.find_element(By.XPATH,"/html/body/div[4]/div/div[1]/div[2]/form/div[3]/span[3]/img").screenshot("code.png") # 定位验证码输入框 shuru=driver.find_element(By.XPATH,"/html/body/div[4]/div/div[1]/div[2]/form/div[3]/span[2]/input") # 识别图片 ocr=ddddocr.DdddOcr() # 读取二进制 with open('code.png','rb')as fp: image=fp.read() result=ocr.classification(image) # 验证码输入 shuru.send_keys(result) sleep(3) # 点击登录 driver.find_element(By.XPATH,"/html/body/div[4]/div/div[1]/div[2]/form/div[5]/a").click() sleep(15) driver.quit()
ddddddocr识别验证码登录。
最新推荐文章于 2024-09-23 14:34:27 发布