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