From 2f071287a49ea30ff72c446f0d13c6500c01b1d5 Mon Sep 17 00:00:00 2001 From: wenxianping <931128603@qq.com> Date: Mon, 14 Jan 2019 09:46:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B2=E7=9F=A5bug=20issue?= =?UTF-8?q?s=EF=BC=9Ahttps://github.com/testerSunshine/12306/issues/177?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ config/configCommon.py | 5 +++-- config/ticket_config.yaml | 25 +++++++++++++------------ init/select_ticket_info.py | 5 +++++ inter/Query.py | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 551e828..81b2483 100755 --- a/README.md +++ b/README.md @@ -80,10 +80,12 @@ - 学生票issues [学生票修改](https://github.com/testerSunshine/12306/issues/47) - 依赖安装不对的问题(ImportError)[requirements.txt问题](https://github.com/testerSunshine/12306/issues/91) - 若快豆子疑问 [点我](https://github.com/testerSunshine/12306/issues/67) + - IOError: 【Errno 0】 Error 问题 [点我](https://github.com/testerSunshine/12306/issues/159) - 测试下单接口是否可用,有两个下单接口,随便用哪个都ok - 如果下载验证码过期或者下载失败的问题,应该是12306封ip的策略,多重试几次,12306现在封服务器(阿里云和腾讯云)ip比较严重,尽量不要放在服务器里面 - 目前12306对服务器ip比较敏感,大家还是在自己家里挂着吧 + - 如果想使用此项目的gui版本,请加群,目前只有mac版本 - 感谢一下小伙伴对本项目提供的帮助 - @sun7127@126.com - @ 才 diff --git a/config/configCommon.py b/config/configCommon.py index d02200a..3d7c618 100755 --- a/config/configCommon.py +++ b/config/configCommon.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import datetime import os +import random import sys import time @@ -102,9 +103,9 @@ def getCacheFile(cacheType): def checkSleepTime(session): now = datetime.datetime.now() if now.hour >= 23 or now.hour < 6: - print(u"12306休息时间,本程序自动停止,明天早上七点将自动运行") + print(u"12306休息时间,本程序自动停止,明天早上六点点将自动运行") open_time = datetime.datetime(now.year, now.month, now.day, 6) if open_time < now: open_time += datetime.timedelta(1) - time.sleep((open_time - now).seconds) + time.sleep((open_time - now).seconds + round(random.uniform(1, 10))) session.call_login() diff --git a/config/ticket_config.yaml b/config/ticket_config.yaml index 5738135..ec3ea08 100755 --- a/config/ticket_config.yaml +++ b/config/ticket_config.yaml @@ -5,7 +5,8 @@ set: # - 2018-01-06 # - 2018-01-07 station_dates: - - "2019-02-02" + - "2019-02-10" + - "2019-02-11" # 是否根据时间范围 和 乘车类型 购票 # 否则将需要手动填写车次 @@ -30,15 +31,15 @@ set: # - "G1353" # - "G1329" station_trains: - - "G6172" - - "G6186" - - "G6154" + - "G6153" + - "G6184" + - "G6173" # 出发城市,比如深圳北,就填深圳就搜得到 - from_station: "广州南" + from_station: "邵阳" # 到达城市 比如深圳北,就填深圳就搜得到 - to_station: "邵阳" + to_station: "深圳北" # 座位(list) 多个座位ex: # - "商务座" @@ -54,18 +55,18 @@ set: - "二等座" # 当余票小于乘车人,如果选择优先提交,则删减联系人和余票数一致在提交 - is_more_ticket: True + is_more_ticket: False # 乘车人(list) 多个乘车人ex: # - "张三" # - "李四" ticke_peoples: - - "文贤平" - - "李梦云" -# - "梁敏" + - "" + - "" + # 12306登录账号(list) 12306account: - - user: "13828728396" + - user: "931128603@qq.com" - pwd: "" # 加入小黑屋时间默认为5分钟,此功能为了防止僵尸票导致一直下单不成功错过正常的票, @@ -106,7 +107,7 @@ email_conf: # 是否开启cdn查询,可以更快的检测票票 1为开启,2为关闭 is_cdn: 1 -# 下单接口分为两种,1 为快速下单,2 是普通下单 +# 下单接口分为两种,1 模拟网页自动捡漏下单(不稳定),2 模拟车次后面的购票按钮下单(稳如老狗) order_type: 2 # 下单模式 1 为预售,整点刷新,刷新间隔0.1-0.5S, 然后会校验时间,比如12点的预售,那脚本就会在12.00整检票,刷新订单 diff --git a/init/select_ticket_info.py b/init/select_ticket_info.py index ab5baeb..0698e60 100755 --- a/init/select_ticket_info.py +++ b/init/select_ticket_info.py @@ -291,14 +291,19 @@ class select: time.sleep(random_time) except PassengerUserException as e: print(e) + break except ticketConfigException as e: print(e) + break except ticketIsExitsException as e: print(e) + break except ticketNumOutException as e: print(e) + break except UserPasswordException as e: print(e) + break except ValueError as e: if e == "No JSON object could be decoded": print(u"12306接口无响应,正在重试") diff --git a/inter/Query.py b/inter/Query.py index 436c567..a709427 100644 --- a/inter/Query.py +++ b/inter/Query.py @@ -95,7 +95,7 @@ class query: continue value = station_ticket.get("data", "") if not value: - print (u'{0}-{1} 车次坐席查询为空,ip网络异常,查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'.format(self.from_station_h, + print(u'{0}-{1} 车次坐席查询为空,ip网络异常,查询url: https://kyfw.12306.cn{2}, 可以手动查询是否有票'.format(self.from_station_h, self.to_station_h, select_url["req_url"])) else: -- GitLab