def get_verify(self): """ 用在线打码获取验证结果 :return: """ result = get_result('verify.png') print('识别结果:', result)
def get_caphe(self): xpath_bds = '//*[@id="verifyImg"]' # 定位节点 - x y坐标 location = self.browser.find_element_by_xpath(xpath_bds).location # 获取宽度和高度 size = self.browser.find_element_by_xpath(xpath_bds).size # 左上角x y坐标 left = location['x'] top = location['y'] # 右下角x y坐标 right = left + size['width'] bottom = top + size['height'] # 截取验证码图片(crop()):对图片进行剪切 img = Image.open('index.png').crop((left,top,right,bottom)) img.save('yzm.png') # 在线打码 result = get_result('yzm.png') print(result)
from ydmapi import get_result result = get_result('yzm5.jpg') print(result)
from ydmapi import get_result import os for root, dirs, filenames in os.walk('./Captcha'): for filename in filenames: result = get_result('./Captcha/' + filename) print(result)
def get_code(self): res = get_result('ydm.png') return res
from ydmapi import get_result res = get_result('test.jpg') print(res)