mirror of https://github.com/testerSunshine/12306
优化预售查询
parent
3d199a0a21
commit
57f223126e
|
@ -15,7 +15,8 @@
|
||||||
- 项目开始
|
- 项目开始
|
||||||
- 服务器启动:
|
- 服务器启动:
|
||||||
- 修改config/ticket_config.yaml文件,按照提示更改自己想要的信息
|
- 修改config/ticket_config.yaml文件,按照提示更改自己想要的信息
|
||||||
- 运行根目录run.py,即可开始
|
- 运行根目录sudo python run.py,即可开始
|
||||||
|
- 由于新增对时功能,请务必用sudo,sudo,sudo 执行,否则会报权限错误,windows打开ide或者cmd请用管理员身份执行python run.py,不需要加sudo
|
||||||
- 如果你的服务器安装了docker,那么就可以docker启动
|
- 如果你的服务器安装了docker,那么就可以docker启动
|
||||||
- 1、docker build -t dockerticket .
|
- 1、docker build -t dockerticket .
|
||||||
- 2、docker run dockerticket python run.py &
|
- 2、docker run dockerticket python run.py &
|
||||||
|
@ -59,11 +60,11 @@
|
||||||
- 测试下单接口是否可用,有两个下单接口,随便用哪个都ok
|
- 测试下单接口是否可用,有两个下单接口,随便用哪个都ok
|
||||||
- 如果下载验证码过期或者下载失败的问题,应该是12306封ip的策略,多重试几次,12306现在封服务器(阿里云和腾讯云)ip比较严重,尽量不要放在服务器里面
|
- 如果下载验证码过期或者下载失败的问题,应该是12306封ip的策略,多重试几次,12306现在封服务器(阿里云和腾讯云)ip比较严重,尽量不要放在服务器里面
|
||||||
- 感谢一下小伙伴对本项目提供的帮助
|
- 感谢一下小伙伴对本项目提供的帮助
|
||||||
- @读,◢
|
- @ sun7127@126.com
|
||||||
- @才
|
- @才
|
||||||
- [更新日志](Update.md)
|
- [更新日志](Update.md)
|
||||||
|
|
||||||
- 如果觉得项目还不错,可怀疑考虑打赏一波,哈哈
|
- 如果觉得项目还不错,可以考虑打赏一波,哈哈
|
||||||
-
|
-
|
||||||

|

|
||||||

|

|
||||||
|
|
|
@ -128,3 +128,8 @@
|
||||||
- 优化已知bug
|
- 优化已知bug
|
||||||
- 开启cdn查询
|
- 开启cdn查询
|
||||||
- 自动识别查询接口
|
- 自动识别查询接口
|
||||||
|
|
||||||
|
- 2018.12.26更新
|
||||||
|
- ticket_config 配置文件增加order_model字段(下单模式)
|
||||||
|
- mac和linux服务器自动对点
|
||||||
|
- 增加预售踩点查询下单,经测试,误差在0.004s
|
||||||
|
|
|
@ -5,7 +5,8 @@ set:
|
||||||
# - 2018-01-06
|
# - 2018-01-06
|
||||||
# - 2018-01-07
|
# - 2018-01-07
|
||||||
station_dates:
|
station_dates:
|
||||||
- "2018-12-29"
|
- "2019-01-27"
|
||||||
|
- "2019-01-26"
|
||||||
|
|
||||||
# 是否根据时间范围 和 乘车类型 购票
|
# 是否根据时间范围 和 乘车类型 购票
|
||||||
# 否则将需要手动填写车次
|
# 否则将需要手动填写车次
|
||||||
|
@ -26,7 +27,7 @@ set:
|
||||||
# take_time: "24:00"
|
# take_time: "24:00"
|
||||||
take_time: "24:00"
|
take_time: "24:00"
|
||||||
|
|
||||||
# 过滤车次(list),格式ex:
|
# 填入需要购买的车次(list),格式ex:
|
||||||
# - "G1353"
|
# - "G1353"
|
||||||
# - "G1329"
|
# - "G1329"
|
||||||
station_trains:
|
station_trains:
|
||||||
|
@ -44,13 +45,16 @@ set:
|
||||||
# - "G6341"
|
# - "G6341"
|
||||||
# - "G1021"
|
# - "G1021"
|
||||||
# - "G99"
|
# - "G99"
|
||||||
- "G6011"
|
# - "G6011"
|
||||||
|
- "D2972"
|
||||||
|
- "D1874"
|
||||||
|
- "D2834"
|
||||||
|
|
||||||
# 出发城市,比如深圳北,就填深圳就搜得到
|
# 出发城市,比如深圳北,就填深圳就搜得到
|
||||||
from_station: "长沙"
|
from_station: "广州南"
|
||||||
|
|
||||||
# 到达城市 比如深圳北,就填深圳就搜得到
|
# 到达城市 比如深圳北,就填深圳就搜得到
|
||||||
to_station: "深圳"
|
to_station: "三江南"
|
||||||
|
|
||||||
# 座位(list) 多个座位ex:
|
# 座位(list) 多个座位ex:
|
||||||
# - "二等座"
|
# - "二等座"
|
||||||
|
@ -65,11 +69,11 @@ set:
|
||||||
# - "张三"
|
# - "张三"
|
||||||
# - "李四"
|
# - "李四"
|
||||||
ticke_peoples:
|
ticke_peoples:
|
||||||
- "文贤平"
|
# - "文贤平"
|
||||||
- "梁敏"
|
- "梁敏"
|
||||||
# 12306登录账号(list)
|
# 12306登录账号(list)
|
||||||
12306account:
|
12306account:
|
||||||
- user: "@qq.com"
|
- user: "931128603@qq.com"
|
||||||
- pwd: ""
|
- pwd: ""
|
||||||
|
|
||||||
# 加入小黑屋时间,此功能为了防止僵尸票导致一直下单不成功错过正常的票
|
# 加入小黑屋时间,此功能为了防止僵尸票导致一直下单不成功错过正常的票
|
||||||
|
@ -83,7 +87,7 @@ auto_code_type: 2
|
||||||
|
|
||||||
# 打码平台账号
|
# 打码平台账号
|
||||||
auto_code_account:
|
auto_code_account:
|
||||||
user: ""
|
user: "931128603"
|
||||||
pwd: ""
|
pwd: ""
|
||||||
|
|
||||||
# 邮箱配置,如果抢票成功,将通过邮件配置通知给您
|
# 邮箱配置,如果抢票成功,将通过邮件配置通知给您
|
||||||
|
@ -108,10 +112,14 @@ email_conf:
|
||||||
host: "smtp.qq.com"
|
host: "smtp.qq.com"
|
||||||
|
|
||||||
# 是否开启cdn查询,可以更快的检测票票 1为开启,2为关闭
|
# 是否开启cdn查询,可以更快的检测票票 1为开启,2为关闭
|
||||||
is_cdn: 2
|
is_cdn: 1
|
||||||
|
|
||||||
# 下单接口分为两种,1 为快速下单,2 是普通下单
|
# 下单接口分为两种,1 为快速下单,2 是普通下单
|
||||||
order_type: 1
|
order_type: 2
|
||||||
|
|
||||||
|
# 下单模式 1 为预售,整点刷新,刷新间隔0.1-0.5S, 然后会校验时间,比如12点的预售,那脚本就会在12.00整检票,刷新订单
|
||||||
|
# 2 是捡漏,捡漏的刷新间隔时间为0.5-3秒,时间间隔长,不容易封ip
|
||||||
|
order_model: 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import wrapcache
|
||||||
|
|
||||||
from agency.cdn_utils import CDNProxy
|
from agency.cdn_utils import CDNProxy
|
||||||
from config import urlConf
|
from config import urlConf
|
||||||
|
from config.AutoSynchroTime import autoSynchroTime
|
||||||
from config.TicketEnmu import ticket
|
from config.TicketEnmu import ticket
|
||||||
from config.configCommon import seat_conf
|
from config.configCommon import seat_conf
|
||||||
from config.configCommon import seat_conf_2
|
from config.configCommon import seat_conf_2
|
||||||
|
@ -42,7 +43,7 @@ class select:
|
||||||
self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, \
|
self.from_station, self.to_station, self.station_dates, self._station_seat, self.is_more_ticket, \
|
||||||
self.ticke_peoples, self.station_trains, self.ticket_black_list_time, \
|
self.ticke_peoples, self.station_trains, self.ticket_black_list_time, \
|
||||||
self.order_type, self.is_by_time, self.train_types, self.departure_time, \
|
self.order_type, self.is_by_time, self.train_types, self.departure_time, \
|
||||||
self.arrival_time, self.take_time = self.get_ticket_info()
|
self.arrival_time, self.take_time, self.order_model = self.get_ticket_info()
|
||||||
self.is_auto_code = _get_yaml()["is_auto_code"]
|
self.is_auto_code = _get_yaml()["is_auto_code"]
|
||||||
self.auto_code_type = _get_yaml()["auto_code_type"]
|
self.auto_code_type = _get_yaml()["auto_code_type"]
|
||||||
self.is_cdn = _get_yaml()["is_cdn"]
|
self.is_cdn = _get_yaml()["is_cdn"]
|
||||||
|
@ -79,16 +80,19 @@ class select:
|
||||||
arrival_time = time_to_minutes(ticket_info_config["set"]["arrival_time"])
|
arrival_time = time_to_minutes(ticket_info_config["set"]["arrival_time"])
|
||||||
take_time = time_to_minutes(ticket_info_config["set"]["take_time"])
|
take_time = time_to_minutes(ticket_info_config["set"]["take_time"])
|
||||||
|
|
||||||
|
# 下单模式
|
||||||
|
order_model = ticket_info_config["order_model"]
|
||||||
|
|
||||||
print u"*" * 20
|
print u"*" * 20
|
||||||
print u"12306刷票小助手,最后更新于2018.12.26,请勿作为商业用途,交流群号:286271084(已满), 请加2群:649992274"
|
print u"12306刷票小助手,最后更新于2019.01.02,请勿作为商业用途,交流群号:286271084(已满), 请加2群:649992274"
|
||||||
if is_by_time:
|
if is_by_time:
|
||||||
method_notie = "购票方式:根据时间区间购票\n可接受最早出发时间:{0}\n可接受最晚抵达时间:{1}\n可接受最长旅途时间:{2}\n可接受列车类型:{3}\n" \
|
method_notie = u"购票方式:根据时间区间购票\n可接受最早出发时间:{0}\n可接受最晚抵达时间:{1}\n可接受最长旅途时间:{2}\n可接受列车类型:{3}\n" \
|
||||||
.format(minutes_to_time(departure_time), minutes_to_time(arrival_time), minutes_to_time(take_time),
|
.format(minutes_to_time(departure_time), minutes_to_time(arrival_time), minutes_to_time(take_time),
|
||||||
" , ".join(train_types))
|
" , ".join(train_types))
|
||||||
else:
|
else:
|
||||||
method_notie = "购票方式:根据候选车次购买\n候选购买车次:{0}".format(",".join(station_trains))
|
method_notie = u"购票方式:根据候选车次购买\n候选购买车次:{0}".format(",".join(station_trains))
|
||||||
print u"当前配置:\n出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票优先提交:{4}\n乘车人:{5}\n" \
|
print u"当前配置:\n出发站:{0}\n到达站:{1}\n乘车日期:{2}\n坐席:{3}\n是否有票优先提交:{4}\n乘车人:{5}\n" \
|
||||||
u"刷新间隔:随机(1-3S)\n{6}\n僵尸票关小黑屋时长:{7}\n 下单接口:{8}\n".format \
|
u"刷新间隔:随机(1-3S)\n{6}\n僵尸票关小黑屋时长:{7}\n 下单接口:{8}\n 下单模式:{9}\n".format \
|
||||||
(
|
(
|
||||||
from_station,
|
from_station,
|
||||||
to_station,
|
to_station,
|
||||||
|
@ -99,9 +103,12 @@ class select:
|
||||||
method_notie,
|
method_notie,
|
||||||
ticket_black_list_time,
|
ticket_black_list_time,
|
||||||
order_type,
|
order_type,
|
||||||
|
order_model
|
||||||
)
|
)
|
||||||
print u"*" * 20
|
print u"*" * 20
|
||||||
return from_station, to_station, station_dates, set_type, is_more_ticket, ticke_peoples, station_trains, ticket_black_list_time, order_type, is_by_time, train_types, departure_time, arrival_time, take_time
|
return from_station, to_station, station_dates, set_type, is_more_ticket, ticke_peoples, station_trains, \
|
||||||
|
ticket_black_list_time, order_type, is_by_time, train_types, departure_time, arrival_time, take_time, \
|
||||||
|
order_model
|
||||||
|
|
||||||
def station_table(self, from_station, to_station):
|
def station_table(self, from_station, to_station):
|
||||||
"""
|
"""
|
||||||
|
@ -187,7 +194,18 @@ class select:
|
||||||
self.call_login()
|
self.call_login()
|
||||||
break
|
break
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
|
if self.order_model is 1:
|
||||||
|
autoSynchroTime()
|
||||||
|
sleep_time_s = 0.1
|
||||||
|
sleep_time_t = 0.5
|
||||||
|
# 测试了一下有微妙级的误差,应该不影响,测试结果:2019-01-02 22:30:00.004555
|
||||||
|
if start_time.strftime("%M:%S") == "29:55" or start_time.strftime("%M:%S") == "59:55":
|
||||||
|
print(u"预售整点模式卡点中")
|
||||||
|
time.sleep(5)
|
||||||
|
print(u"预售模式执行")
|
||||||
|
else:
|
||||||
|
sleep_time_s = 0.5
|
||||||
|
sleep_time_t = 3
|
||||||
q = query(session=self,
|
q = query(session=self,
|
||||||
from_station=from_station,
|
from_station=from_station,
|
||||||
to_station=to_station,
|
to_station=to_station,
|
||||||
|
@ -243,7 +261,7 @@ class select:
|
||||||
self.ticke_peoples)
|
self.ticke_peoples)
|
||||||
sor.sendSubmitOrderRequest()
|
sor.sendSubmitOrderRequest()
|
||||||
else:
|
else:
|
||||||
random_time = round(random.uniform(0.5, 0.5), 2)
|
random_time = round(random.uniform(sleep_time_s, sleep_time_t), 2)
|
||||||
print(u"正在第{0}次查询 随机停留时长:{6} 乘车日期: {1} 车次:{2} 查询无票 cdn轮询IP:{4}当前cdn总数:{5} 总耗时:{3}ms".format(num,
|
print(u"正在第{0}次查询 随机停留时长:{6} 乘车日期: {1} 车次:{2} 查询无票 cdn轮询IP:{4}当前cdn总数:{5} 总耗时:{3}ms".format(num,
|
||||||
",".join(
|
",".join(
|
||||||
self.station_dates),
|
self.station_dates),
|
||||||
|
@ -251,7 +269,9 @@ class select:
|
||||||
self.station_trains),
|
self.station_trains),
|
||||||
(
|
(
|
||||||
datetime.datetime.now() - start_time).microseconds / 1000,
|
datetime.datetime.now() - start_time).microseconds / 1000,
|
||||||
queryResult.get("cdn", None),
|
queryResult.get(
|
||||||
|
"cdn",
|
||||||
|
None),
|
||||||
len(
|
len(
|
||||||
self.cdn_list),
|
self.cdn_list),
|
||||||
random_time))
|
random_time))
|
||||||
|
|
|
@ -4,4 +4,5 @@ PyYAML==3.12
|
||||||
six==1.10.0
|
six==1.10.0
|
||||||
requests==2.18.4
|
requests==2.18.4
|
||||||
Pillow==5.0.0
|
Pillow==5.0.0
|
||||||
wrapcache==1.0.8
|
wrapcache==1.0.8
|
||||||
|
ntplib==0.3.3
|
Loading…
Reference in New Issue