def getRandCode(is_auto_code, auto_code_type, result): """ 识别验证码 :return: 坐标 """ try: if is_auto_code: if auto_code_type == 1: print(u"打码兔已关闭, 如需使用自动识别,请使用如果平台 auto_code_type == 2") return if auto_code_type == 2: rc = RClient(_get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]) # im = open('./tkcode', 'rb').read() Result = rc.rk_create(result, 6113) if "Result" in Result: return codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) else: if "Error" in Result and Result["Error"]: print( u"打码平台错误: {0}, 请登录打码平台查看-http://www.ruokuai.com/client/index?6726" .format(Result["Error"])) return "" else: img = Image.open('./tkcode') img.show() return codexy() except Exception as e: print(e)
def getRandCode(self): """ 识别验证码 :return: 坐标 """ try: if self.is_aotu_code: if self.aotu_code_type == 1: return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], "./tkcode").main() elif self.aotu_code_type == 2: rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]) im = open('./tkcode', 'rb').read() Result = rc.rk_create(im, 6113) if "Result" in Result: return self.codexy(Ofset=",".join( list(Result["Result"])), is_raw_input=False) else: if "Error" in Result and Result["Error"]: print Result["Error"] return "" else: img = Image.open('./tkcode') img.show() return self.codexy() except: pass
def getRandCode(self): """ 识别验证码 :return: 坐标 """ try: if self.is_aotu_code: if self.aotu_code_type == 1: return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], "./tkcode").main() elif self.aotu_code_type == 2: rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]) im = open('./tkcode', 'rb').read() Result = rc.rk_create(im, 6113) if "Result" in Result: return self.codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) else: if "Error" in Result and Result["Error"]: print Result["Error"] return "" else: img = Image.open('./tkcode') img.show() return self.codexy() except: pass
def readImg(self, code_url): """ 增加手动打码,只是登录接口,完全不用担心提交订单效率 思路 1.调用PIL显示图片 2.图片位置说明,验证码图片中每个图片代表一个下标,依次类推,1,2,3,4,5,6,7,8 3.控制台输入对应下标,按照英文逗号分开,即可手动完成打码, :return: """ print ("下载验证码...") codeimgUrl = code_url img_path = './tkcode' result = self.httpClint.send(codeimgUrl, is_logger=False) try: open(img_path, 'wb').write(result) if self.is_aotu_code: if self.aotu_code_type == 1: return DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"], img_path).main() elif self.aotu_code_type == 2: rc = RClient(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]) im = open('./tkcode', 'rb').read() Result = rc.rk_create(im, 6113) if "Result" in Result: return self.codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) else: if "Error" in Result and Result["Error"]: print Result["Error"] return "" else: img = Image.open('./tkcode') img.show() return self.codexy() except OSError as e: print (e) return ""
def getRandCode(is_auto_code, auto_code_type, result): """ 识别验证码 :return: 坐标 """ try: if is_auto_code: if auto_code_type == 1: print(u"打码兔已关闭, 如需使用自动识别,请使用如果平台 auto_code_type == 2") return if auto_code_type == 2: rc = RClient(_get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]) # im = open('./tkcode', 'rb').read() Result = rc.rk_create(result, 6113) if "Result" in Result: return codexy(Ofset=",".join(list(Result["Result"])), is_raw_input=False) else: if "Error" in Result and Result["Error"]: print(u"打码平台错误: {0}, 请登录打码平台查看-http://www.ruokuai.com/client/index?6726".format(Result["Error"])) return "" else: img = Image.open('./tkcode.png') img.show() return codexy() except Exception as e: print(e)