Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
优化查询逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
testerSunshine committed Dec 31, 2018
1 parent 2465d61 commit 0e6f2ce
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
26 changes: 13 additions & 13 deletions config/urlConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -207,7 +207,7 @@
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -218,7 +218,7 @@
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -229,7 +229,7 @@
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -240,7 +240,7 @@
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -251,7 +251,7 @@
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": False,
"is_json": False,
Expand All @@ -262,7 +262,7 @@
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -273,7 +273,7 @@
"Referer": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -284,7 +284,7 @@
"Referer": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": False,
"is_json": False,
Expand All @@ -295,7 +295,7 @@
"Referer": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -307,7 +307,7 @@
"Host": "kyfw.12306.cn",
"Content-Type": 1,
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -319,7 +319,7 @@
"Host": "kyfw.12306.cn",
"Content-Type": 1,
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand All @@ -331,7 +331,7 @@
"Content-Type": 1,
"Host": "kyfw.12306.cn",
"re_try": 10,
"re_time": 0.1,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
Expand Down
6 changes: 3 additions & 3 deletions init/select_ticket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ def main(self):
sor.sendSubmitOrderRequest()
else:
random_time = round(random.uniform(0.5, 0.5), 2)
time.sleep(random_time)
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(
self.station_dates),
",".join(
Expand All @@ -255,7 +254,8 @@ def main(self):
queryResult.get("cdn", None),
len(
self.cdn_list),
random_time)
random_time))
time.sleep(random_time)
except PassengerUserException as e:
print e.message
break
Expand Down
2 changes: 1 addition & 1 deletion inter/CheckUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def sendCheckUser(self):
检查用户登录, 检查间隔为2分钟
:return:
"""
CHENK_TIME = 1
CHENK_TIME = 0.3
if wrapcache.get("user_time") is None:
check_user_url = self.session.urls["check_user_url"]
data = {"_json_att": ""}
Expand Down
3 changes: 1 addition & 2 deletions inter/Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def __init__(self, session, from_station, to_station, from_station_h, to_station
self.arrival_time = session.arrival_time
self.take_time = session.take_time


@classmethod
def station_seat(self, index):
"""
Expand Down Expand Up @@ -90,7 +89,7 @@ def sendQuery(self):
self.session.queryUrl)
station_ticket = self.httpClint.send(select_url)
if station_ticket.get("c_url", ""):
print(station_ticket.get("c_url", ""))
print(u"设置当前查询url为: {}".format(station_ticket.get("c_url", "")))
self.session.queryUrl = station_ticket.get("c_url", "") # 重设查询接口
continue
value = station_ticket.get("data", "")
Expand Down
1 change: 0 additions & 1 deletion inter/SubmitOrderRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def sendSubmitOrderRequest(self):
submitResult = self.session.httpClint.send(submit_station_url, self.data_apr())
if 'data' in submitResult and submitResult['data']:
if submitResult['data'] == 'N':
print (u'出票成功')
coi = checkOrderInfo(self.session, self.train_no, self.set_type, self.passengerTicketStrList,
self.oldPassengerStr,
self.train_date, self.ticke_peoples)
Expand Down

0 comments on commit 0e6f2ce

Please sign in to comment.