如何利用python+Selenium对登录的验证码进行验证?

python+Selenium自动识别验证码Fg.save_screenshot(‘D:\HuaYu\image\image.png‘)ce = Fg.find_element_by_id("ensure")  # 具体的id要用F12自行查看print(ce.location)im = Image.open(‘D:\HuaYu\image\image.png‘) 根据图片调整位置img = im.crop((860,507,945,532))print(img)img.save(‘D:\HuaYu\image\image01.png‘)  # 这里就是截取到的验证码图片image2=Image.open(‘D:\HuaYu\image\image01.png‘)sharp_img=ImageEnhance.Contrast(image2).enhance(2.0)#将图片二进制化sharp_img.save(‘D:\HuaYu\image\image02.png‘)#形成新的图片sleep(1)codeText=pytesseract.image_to_string(Image.open(‘D:\HuaYu\image\image02.png‘).convert(‘L‘))print(codeText)newcode=codeText.replace(" ", ‘‘)#去掉图片中多余的空格Fg.find_element_by_name(‘code‘).send_keys(newcode)