Skip to content

Commit

Permalink
增加cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
testerSunshine committed Dec 18, 2019
1 parent 9593133 commit 7c9ad86
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions TickerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@

# 保护12306官网请求频率,设置随机请求时间,原则为5分钟不大于80次
# 最大间隔请求时间
MAX_TIME = 5
MAX_TIME = 3
# 最小间隔请求时间
MIN_TIME = 3
MIN_TIME = 1

# 软件版本
RE_VERSION = "1.2.002"
2 changes: 1 addition & 1 deletion agency/cdn_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run(self):
http._cdn = cdn.replace("\n", "")
start_time = datetime.datetime.now()
rep = http.send(url)
if rep and "message" not in rep and (datetime.datetime.now() - start_time).microseconds / 1000 < 1000:
if rep and "message" not in rep and (datetime.datetime.now() - start_time).microseconds / 1000 < 3000:
if cdn.replace("\n", "") not in cdn_list: # 如果有重复的cdn,则放弃加入
print(f"加入cdn: {cdn}")
cdn_list.append(cdn.replace("\n", ""))
Expand Down
2 changes: 1 addition & 1 deletion init/select_ticket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def main(self):
else:
random_time = round(random.uniform(sleep_time_s, sleep_time_t), 2)
nateMsg = ' 无候补机会' if TickerConfig.ORDER_TYPE == 2 else ""
print(f"正在第{num}次查询 随机停留时长{random_time} 乘车日期: {','.join(TickerConfig.STATION_DATES)} 车次:{','.join(TickerConfig.STATION_TRAINS) or '所有车次'} 下单无票{nateMsg} 耗时:{(datetime.datetime.now() - now).microseconds / 1000}ms")
print(f"正在第{num}次查询 停留时间{random_time} 乘车日期: {','.join(TickerConfig.STATION_DATES)} 车次:{','.join(TickerConfig.STATION_TRAINS) or '所有车次'} 下单无票{nateMsg} 耗时:{(datetime.datetime.now() - now).microseconds / 1000} {queryResult.get('cdn')}")
time.sleep(random_time)
except PassengerUserException as e:
print(e)
Expand Down

0 comments on commit 7c9ad86

Please sign in to comment.