mirror of https://github.com/testerSunshine/12306
update version 1.1.113
parent
e200c28a62
commit
399f9b6626
|
@ -6,16 +6,17 @@
|
|||
# 刷票模式:1=刷票 2=候补+刷票
|
||||
TICKET_TYPE = 2
|
||||
|
||||
|
||||
# 出发日期(list) "2018-01-06", "2018-01-07"
|
||||
STATION_DATES = [
|
||||
"2019-09-20"
|
||||
"2019-10-01"
|
||||
]
|
||||
|
||||
# 填入需要购买的车次(list),"G1353"
|
||||
# 修改车次填入规则,注:(以前设置的车次逻辑不变),如果车次填入为空,那么就是当日乘车所有车次都纳入筛选返回
|
||||
STATION_TRAINS = [
|
||||
"",
|
||||
]
|
||||
|
||||
# 出发城市,比如深圳北,就填深圳就搜得到
|
||||
FROM_STATION = ""
|
||||
|
||||
|
@ -85,7 +86,6 @@ SERVER_CHAN_CONF = {
|
|||
"secret": ""
|
||||
}
|
||||
|
||||
|
||||
# 是否开启cdn查询,可以更快的检测票票 1为开启,2为关闭
|
||||
IS_CDN = 1
|
||||
|
||||
|
@ -106,13 +106,12 @@ IS_PROXY = 0
|
|||
|
||||
# 预售放票时间, 如果是捡漏模式,可以忽略此操作
|
||||
OPEN_TIME = "13:00:00"
|
||||
|
||||
# 1=使用selenium获取devicesID
|
||||
# 2=使用网页端/otn/HttpZF/logdevice获取devicesId,这个接口的算法目前可能有点问题,如果登录一直302的请改为配置1
|
||||
COOKIE_TYPE = 1
|
||||
# 如果COOKIE_TYPE=2,则需配置chromeDriver路径,下载地址http://chromedriver.storage.googleapis.com/index.html
|
||||
# 如果COOKIE_TYPE=1,则需配置chromeDriver路径,下载地址http://chromedriver.storage.googleapis.com/index.html
|
||||
# chromedriver配置版本只要和chrome的大版本匹配就行
|
||||
CHROME_PATH = "/Users/wenxianping/Downloads/chromedriver"
|
||||
CHROME_PATH = ""
|
||||
|
||||
# 1=>为一直随机ua,2->只启动的时候随机一次ua
|
||||
RANDOM_AGENT = 2
|
||||
|
@ -129,5 +128,10 @@ PASSENGER_TICKER_STR = {
|
|||
'硬卧': 3,
|
||||
}
|
||||
|
||||
# 保护12306官网请求频率,设置随机请求时间,原则为5分钟不大于80次
|
||||
# 最大间隔请求时间
|
||||
MAX_TIME = 5
|
||||
# 最小间隔请求时间
|
||||
MIN_TIME = 3
|
||||
# 软件版本
|
||||
RE_VERSION = "1.1.112"
|
||||
RE_VERSION = "1.1.113"
|
||||
|
|
|
@ -180,3 +180,8 @@
|
|||
|
||||
- 2019.09.09更新
|
||||
- 优化候补逻辑
|
||||
|
||||
- 2019.09.15更新
|
||||
- 增长随机停留时长
|
||||
- 增长用户心跳时间,减少对服务器压力
|
||||
- 优化下单逻辑
|
||||
|
|
|
@ -17,7 +17,6 @@ def getDrvicesID(session):
|
|||
driver = webdriver.Chrome(executable_path=TickerConfig.CHROME_PATH)
|
||||
driver.get("https://www.12306.cn/index/index.html")
|
||||
time.sleep(10)
|
||||
|
||||
for c in driver.get_cookies():
|
||||
cookie = dict()
|
||||
print()
|
||||
|
|
|
@ -244,9 +244,9 @@ urls = {
|
|||
"req_type": "post",
|
||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
||||
"Host": "kyfw.12306.cn",
|
||||
"re_try": 10,
|
||||
"re_time": 0.3,
|
||||
"s_time": 0.1,
|
||||
"re_try": 1,
|
||||
"re_time": 1,
|
||||
"s_time": 1,
|
||||
"is_logger": True,
|
||||
"is_json": True,
|
||||
},
|
||||
|
|
|
@ -58,7 +58,7 @@ class select:
|
|||
print(u"*" * 50)
|
||||
print(f"检查当前版本为: {TickerConfig.RE_VERSION}")
|
||||
print(u"检查当前python版本为:{},目前版本只支持3.6以上".format(sys.version.split(" ")[0]))
|
||||
print(u"12306刷票小助手,最后更新于2019.09.09,请勿作为商业用途,交流群号:"
|
||||
print(u"12306刷票小助手,最后更新于2019.09.15,请勿作为商业用途,交流群号:"
|
||||
u" 1群:286271084(已满)\n"
|
||||
u" 2群:649992274(已满)\n"
|
||||
u" 3群:632501142(已满)\n"
|
||||
|
@ -117,6 +117,7 @@ class select:
|
|||
urls = self.urls["loginInitCdn"]
|
||||
http._cdn = cdn[i].replace("\n", "")
|
||||
start_time = datetime.datetime.now()
|
||||
time.sleep(3)
|
||||
rep = http.send(urls)
|
||||
if rep and "message" not in rep and (datetime.datetime.now() - start_time).microseconds / 1000 < 500:
|
||||
if cdn[i].replace("\n", "") not in self.cdn_list: # 如果有重复的cdn,则放弃加入
|
||||
|
@ -174,8 +175,8 @@ class select:
|
|||
break
|
||||
time.sleep(0.0001)
|
||||
else:
|
||||
sleep_time_s = 0.5
|
||||
sleep_time_t = 3
|
||||
sleep_time_s = TickerConfig.MIN_TIME
|
||||
sleep_time_t = TickerConfig.MAX_TIME
|
||||
q = query(session=self,
|
||||
from_station=from_station,
|
||||
to_station=to_station,
|
||||
|
|
|
@ -16,9 +16,9 @@ class checkUser:
|
|||
检查用户登录, 检查间隔为2分钟
|
||||
:return:
|
||||
"""
|
||||
CHENK_TIME = 0.3
|
||||
CHENK_TIME = 1
|
||||
while 1:
|
||||
time.sleep(0.1) # 防止cpu占用过高
|
||||
time.sleep(3) # 防止cpu占用过高
|
||||
configCommon.checkSleepTime(self.session) # 修复晚上查询线程休眠时,检查登录线程为休眠,造成快豆迅速消耗
|
||||
if wrapcache.get("user_time") is None:
|
||||
check_user_url = self.session.urls["check_user_url"]
|
||||
|
|
|
@ -18,6 +18,7 @@ class query:
|
|||
ticke_peoples_num, station_dates=None, ):
|
||||
self.session = session
|
||||
self.httpClint = HTTPClient(TickerConfig.IS_PROXY)
|
||||
self.httpClint.set_cookies(self.session.cookies)
|
||||
self.urls = urlConf.urls
|
||||
self.from_station = from_station
|
||||
self.to_station = to_station
|
||||
|
@ -47,7 +48,15 @@ class query:
|
|||
return seat[index]
|
||||
|
||||
def check_is_need_train(self, ticket_info):
|
||||
return ticket_info[3] in self.station_trains
|
||||
"""
|
||||
判断车次是否为想要的车次,如果ticket_info为空,那么就不校验车次,直接返回True
|
||||
:param ticket_info:
|
||||
:return:
|
||||
"""
|
||||
if self.station_dates:
|
||||
return ticket_info[3] in self.station_trains
|
||||
else:
|
||||
return True
|
||||
|
||||
def sendQuery(self):
|
||||
"""
|
||||
|
|
|
@ -131,8 +131,8 @@ class HTTPClient(object):
|
|||
method = "get"
|
||||
self.resetHeaders()
|
||||
if TickerConfig.RANDOM_AGENT is 1:
|
||||
self.setHeadersReferer(urls["Referer"])
|
||||
self.setHeadersUserAgent()
|
||||
self.setHeadersUserAgent()
|
||||
self.setHeadersReferer(urls["Referer"])
|
||||
if is_logger:
|
||||
logger.log(
|
||||
u"url: {0}\n入参: {1}\n请求方式: {2}\n".format(req_url, data, method, ))
|
||||
|
|
Loading…
Reference in New Issue