实现 新版登录逻辑

优化 订票逻辑
pull/23/head
wenxianping 2018-01-21 09:12:15 +08:00
parent aa6d628c82
commit d7c5c7215c
6 changed files with 11 additions and 10 deletions

View File

@ -170,4 +170,10 @@
- 更新请求第三方库
- 优化若干代码,小伙伴尽情的放肆起来
- 2018.1.21跟新
- 修复若干bug
- 合并dev
- 恢复之前因为12306改版引起的订票功能

View File

@ -1,6 +1,5 @@
# -*- coding: utf8 -*-
__author__ = 'MR.wen'
import os
import yaml

View File

@ -85,5 +85,4 @@ urls = {
"req_url": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
"req_type": "post"
}
}

View File

@ -149,7 +149,7 @@ class GoLogin:
if messages.find("密码输入错误") is not -1:
raise UserPasswordException("{0}".format(messages))
else:
print ("登录失败: {0}".format("".join(tresult)))
print ("登录失败: {0}".format(messages))
print ("尝试重新登陆")
return False
else:
@ -180,6 +180,8 @@ class GoLogin:
:return:
"""
user, passwd = _get_yaml()["set"]["12306count"][0]["uesr"], _get_yaml()["set"]["12306count"][1]["pwd"]
if not user or not passwd:
raise UserPasswordException("温馨提示: 用户名或者密码为空,请仔细检查!")
login_num = 0
while True:
self.cookietp()

View File

@ -1,17 +1,14 @@
# -*- coding=utf-8 -*-
import json
import datetime
import random
import re
import socket
import urllib
import sys
import time
from collections import OrderedDict
from config import urlConf
from init import login
from config.emailConf import sendEmail
from config.ticketConf import _get_yaml
from damatuCode.damatuWeb import DamatuApi
@ -141,7 +138,7 @@ class select:
获取提交车票请求token
:return: token
"""
initdc_url = self.confUrl["initdc_url"]["req+url"]
initdc_url = self.confUrl["initdc_url"]["req_url"]
initdc_result = self.httpClint.send(initdc_url)
token_name = re.compile(r"var globalRepeatSubmitToken = '(\S+)'")
ticketInfoForPassengerForm_name = re.compile(r'var ticketInfoForPassengerForm=(\{.+\})?')
@ -187,7 +184,7 @@ class select:
select_url = self.confUrl["select_url"]["req_url"].format(
self.station_date if station_date is None else station_date, from_station, to_station)
station_ticket = self.httpClint.send(select_url)
return station_ticket
return json.loads(station_ticket)
def submitOrderRequestImplement(self, from_station, to_station,):
"""
@ -652,8 +649,6 @@ class select:
print(e.message)
if __name__ == '__main__':
login()
# a = select('上海', '北京')

BIN
tkcode

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB