mirror of https://github.com/testerSunshine/12306
修复python3保存图片编码问题
parent
7674929eef
commit
2a7c84f210
|
@ -78,7 +78,6 @@ urls = {
|
||||||
"s_time": 0.1,
|
"s_time": 0.1,
|
||||||
"is_logger": True,
|
"is_logger": True,
|
||||||
"is_json": False,
|
"is_json": False,
|
||||||
"not_decode": True,
|
|
||||||
},
|
},
|
||||||
"codeCheck": { # 验证码校验
|
"codeCheck": { # 验证码校验
|
||||||
"req_url": "/passport/captcha/captcha-check",
|
"req_url": "/passport/captcha/captcha-check",
|
||||||
|
@ -140,7 +139,7 @@ urls = {
|
||||||
"is_json": False,
|
"is_json": False,
|
||||||
},
|
},
|
||||||
"getDevicesId": { # 获取用户信息
|
"getDevicesId": { # 获取用户信息
|
||||||
"req_url": "/otn/HttpZF/logdevice?algID=sV3XbAmeRg&hashCode=9JGmYn7tyQpz7ARsg5hs0afNuPy3NlZXSCye9VHEJII&FMQw=0&q4f3=zh-CN&VPIf=1&custID=133&VEek=unknown&dzuS=0&yD16=1&EOQP=1acda25d532249b0b1635671927a47e0&jp76=69f27b80c0ec8437d2a1f4278674e7fb&hAqN=MacIntel&platform=WEB&ks0Q=e848b8c6800147e416e6663782ca3789&TeRS=831x1440&tOHY=24xx900x1440&Fvje=i1l1o1s1&q5aJ=-8&wNLf=99115dfb07133750ba677d055874de87&0aew=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_13_4)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/11.1%20Safari/605.1.15&E3gR=3492a53db5709ba4cade22e8fe879dc1×tamp=1554304524960",
|
"req_url": "/otn/HttpZF/logdevice?algID=sV3XbAmeRg&hashCode=9JGmYn7tyQpz7ARsg5hs0afNuPy3NlZXSCye9VHEJII&FMQw=0&q4f3=zh-CN&VPIf=1&custID=133&VEek=unknown&dzuS=0&yD16=1&EOQP=1acda25d532249b0b1635671927a47e0&jp76=69f27b80c0ec8437d2a1f4278674e7fb&hAqN=MacIntel&platform=WEB&ks0Q=e848b8c6800147e416e6663782ca3789&TeRS=831x1440&tOHY=24xx900x1440&Fvje=i1l1o1s1&q5aJ=-8&wNLf=99115dfb07133750ba677d055874de87&0aew=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_13_4)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/11.1%20Safari/605.1.15&E3gR=3492a53db5709ba4cade22e8fe879dc1×tamp={0}",
|
||||||
"req_type": "get",
|
"req_type": "get",
|
||||||
"Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/",
|
"Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/",
|
||||||
"Host": "kyfw.12306.cn",
|
"Host": "kyfw.12306.cn",
|
||||||
|
|
|
@ -11,7 +11,6 @@ from inter.GetRandCode import getRandCode
|
||||||
from inter.LoginAysnSuggest import loginAysnSuggest
|
from inter.LoginAysnSuggest import loginAysnSuggest
|
||||||
from inter.LoginConf import loginConf
|
from inter.LoginConf import loginConf
|
||||||
from myException.UserPasswordException import UserPasswordException
|
from myException.UserPasswordException import UserPasswordException
|
||||||
from myException.balanceException import balanceException
|
|
||||||
|
|
||||||
|
|
||||||
class GoLogin:
|
class GoLogin:
|
||||||
|
@ -141,7 +140,9 @@ class GoLogin:
|
||||||
# result = getPassCodeNewOrderAndLogin(session=self.session, imgType="login")
|
# result = getPassCodeNewOrderAndLogin(session=self.session, imgType="login")
|
||||||
self.auth()
|
self.auth()
|
||||||
|
|
||||||
devicesIdRsp = self.session.httpClint.send(self.session.urls.get("getDevicesId"))
|
devicesIdUrl = copy.deepcopy(self.session.urls["getDevicesId"])
|
||||||
|
devicesIdUrl["req_url"] = devicesIdUrl["req_url"].format(int(time.time() * 1000))
|
||||||
|
devicesIdRsp = self.session.httpClint.send(devicesIdUrl)
|
||||||
devicesId = eval(devicesIdRsp.split("(")[1].split(")")[0].replace("'", ""))["dfp"]
|
devicesId = eval(devicesIdRsp.split("(")[1].split(")")[0].replace("'", ""))["dfp"]
|
||||||
if devicesId:
|
if devicesId:
|
||||||
self.session.httpClint.set_cookies(RAIL_DEVICEID=devicesId)
|
self.session.httpClint.set_cookies(RAIL_DEVICEID=devicesId)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
import base64
|
||||||
import copy
|
import copy
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ def getPassCodeNewOrderAndLogin1(session, imgType):
|
||||||
img.write(result)
|
img.write(result)
|
||||||
except Exception:
|
except Exception:
|
||||||
with open(img_path, 'wb') as img:
|
with open(img_path, 'wb') as img:
|
||||||
img.write(result)
|
img.write(base64.b64decode(result))
|
||||||
return result
|
return result
|
||||||
except OSError:
|
except OSError:
|
||||||
print(u"验证码下载失败,可能ip被封,确认请手动请求: {0}".format(codeImgUrl))
|
print(u"验证码下载失败,可能ip被封,确认请手动请求: {0}".format(codeImgUrl))
|
||||||
|
|
Loading…
Reference in New Issue