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()