代码没有报错 却识别不了验证码
from selenium import webdriver
from PIL import Image
from ShowapiRequest import ShowapiRequest
import time
driver = webdriver.Chrome()
driver.get(“https://zwdtuser.sh.gov.cn/uc/login/login.jsp”)
time.sleep(5)
def get_code_image(file_name):
driver.save_screenshot(file_name)
code_element = driver.find_element_by_id(“img”)
print(code_element.location)#坐标定位验证码位置(“x”:123,“y”:345)
left = code_element.location[‘x’]
top = code_element.location[‘y’]
right = code_element.size[‘width’]+left
height = code_element.size[‘height’]+top
im = Image.open(file_name)
img = im.crop((left,top,right,height))
img.save(file_name)
def code_online(file_name):
r = ShowapiRequest(“http://route.shouapi.com/184-5”, “id”, “ccad”)#账个人户和密码隐藏
r.addBodyPara(“img_base64”, “”)
r.addBodyPara(“typeId”,“35”)
r.addBodyPara(“convert_to_jpg”,“0”)
r.addBodyPara(“image”,file_name)
res = r.post()
text = res.json()[‘showapi_res_body’][‘Result’]
print(res.text)
return text
driver.close()