python 自动输入验证码

from selenium import webdriver
from time import sleep
import ddddocr
driver = webdriver.Chrome()
driver.get('http://121.41.14.39:8088/index.html')
driver.find_element_by_css_selector('#username').send_keys('sq1')
driver.find_element_by_css_selector('#password').send_keys('123')
ele_img = driver.find_element_by_css_selector('img')
ocr = ddddocr.DdddOcr()
text = ocr.classification(ele_img.screenshot_as_png)
# with open('code.png','wb') as f:
# f.write(ele_img.screenshot_as_png) #bytes类型,可以保存截图
sleep(2)
driver.find_element_by_css_selector('#code').send_keys(text)
sleep(2)
driver.find_element_by_css_selector('#submitButton').click()
posted @ 2021-12-11 17:24  持地悲道  阅读(689)  评论(0编辑  收藏  举报