diff --git a/README.md b/README.md index 2c4ac8e..ed17b64 100644 --- a/README.md +++ b/README.md @@ -170,4 +170,10 @@ - 更新请求第三方库 - 优化若干代码,小伙伴尽情的放肆起来 +- 2018.1.21跟新 + - 修复若干bug + - 合并dev + - 恢复之前因为12306改版引起的订票功能 + + diff --git a/config/ticketConf.py b/config/ticketConf.py index f67221d..ea70f22 100644 --- a/config/ticketConf.py +++ b/config/ticketConf.py @@ -1,6 +1,5 @@ # -*- coding: utf8 -*- __author__ = 'MR.wen' - import os import yaml diff --git a/config/urlConf.py b/config/urlConf.py index d2e7651..59c6afd 100644 --- a/config/urlConf.py +++ b/config/urlConf.py @@ -85,5 +85,4 @@ urls = { "req_url": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete", "req_type": "post" } - } \ No newline at end of file diff --git a/init/login.py b/init/login.py index 6fbb34d..c67e265 100644 --- a/init/login.py +++ b/init/login.py @@ -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() diff --git a/init/select_ticket_info.py b/init/select_ticket_info.py index 8754487..3f73178 100644 --- a/init/select_ticket_info.py +++ b/init/select_ticket_info.py @@ -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('上海', '北京') diff --git a/tkcode b/tkcode index d7eb6d9..e71efdc 100644 Binary files a/tkcode and b/tkcode differ