UI自动化关于图片验证码识别的解决方法




def __save_screenshot(self):
self.driver.save_screenshot('full_snap.png')
self.page_snap_obj = Image.open('full_snap.png')
return self.page_snap_obj

def __request_re(self):
self.img = self.driver.find_element_by_xpath('//*[@id="verifyImg"]')
self.location = self.img.location
self.size = self.img.size
left = self.location['x']
top = self.location['y']
right = left + self.size['width']
bottom = top + self.size['height']
page = self.__save_screenshot()
image_obj = page.crop((left, top, right, bottom))
image_obj.save('code002.png')
  
  # 别人的接口图片训练识别
# url1 = 'http://47.106.210.173:19952/captcha/v3'
url = 'http://47.98.142.71:19952/captcha/v3'
image = open('code002.png', 'rb')
r = requests.post(url, image)
t = r.content.decode()
s = json.loads(t)
m = s['message']
print(m)
return m


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM