验证码图片改后缀

pull/108/head
wenxianping 2019-01-07 17:48:41 +08:00
parent ec38172b3d
commit e6ce310eca
5 changed files with 19 additions and 15 deletions

View File

@ -14,3 +14,7 @@ def _get_yaml():
s = yaml.load(f) s = yaml.load(f)
f.close() f.close()
return s.decode() if isinstance(s, bytes) else s return s.decode() if isinstance(s, bytes) else s
if __name__ == '__main__':
print(_get_yaml())

View File

@ -18,11 +18,11 @@ def getPassCodeNewOrderAndLogin(session, imgType):
codeImgUrl = copy.deepcopy(session.urls["codeImgByOrder"]) codeImgUrl = copy.deepcopy(session.urls["codeImgByOrder"])
codeImgUrl["req_url"] = codeImgUrl["req_url"].format(random.random()) codeImgUrl["req_url"] = codeImgUrl["req_url"].format(random.random())
print (u"下载验证码...") print (u"下载验证码...")
img_path = './tkcode' img_path = './tkcode.png'
result = session.httpClint.send(codeImgUrl) result = session.httpClint.send(codeImgUrl)
try: try:
if isinstance(result, dict): if isinstance(result, dict):
print(u"下载验证码失败, 请手动检查是否ip被封或者重试请求地址{}".format(codeImgUrl.get("req_url"))) print(u"下载验证码失败, 请手动检查是否ip被封或者重试请求地址https://kyfw.12306.cn/{}".format(codeImgUrl.get("req_url")))
return False return False
else: else:
print(u"下载验证码成功") print(u"下载验证码成功")

View File

@ -26,7 +26,7 @@ def getRandCode(is_auto_code, auto_code_type, result):
print(u"打码平台错误: {0}, 请登录打码平台查看-http://www.ruokuai.com/client/index?6726".format(Result["Error"])) print(u"打码平台错误: {0}, 请登录打码平台查看-http://www.ruokuai.com/client/index?6726".format(Result["Error"]))
return "" return ""
else: else:
img = Image.open('./tkcode') img = Image.open('./tkcode.png')
img.show() img.show()
return codexy() return codexy()
except Exception as e: except Exception as e:
@ -46,7 +46,7 @@ def codexy(Ofset=None, is_raw_input=True):
| 5 | 6 | 7 | 8 | | 5 | 6 | 7 | 8 |
***************** *****************
""") """)
print(u"验证码分为8个对应上面数字例如第一和第二张输入1, 2") print(u"验证码分为8个对应上面数字例如第一和第二张输入1, 2 如果开启cdn查询的话会冲掉提示直接鼠标点击命令行获取焦点输入即可不要输入空格")
Ofset = raw_input(u"输入对应的验证码: ") Ofset = raw_input(u"输入对应的验证码: ")
Ofset = Ofset.replace("", ",") Ofset = Ofset.replace("", ",")
select = Ofset.split(',') select = Ofset.split(',')

BIN
tkcode

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB