Skip to content

Commit 05f1486

Browse files
hellozjftesterSunshine
authored andcommitted
动态更新queryUrl
初始化的时候,根据初始化的结果,动态设置queryUrl,避免每次12306官网换了queryUrl之后都要手动修改代码
1 parent 8258d3d commit 05f1486

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

inter/LiftTicketInit.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# coding=utf-8
2+
import re
23

34

45
class liftTicketInit:
@@ -11,7 +12,13 @@ def reqLiftTicketInit(self):
1112
:return:
1213
"""
1314
urls = self.session.urls["left_ticket_init"]
14-
self.session.httpClint.send(urls)
15+
# 获取初始化的结果
16+
result = self.session.httpClint.send(urls)
17+
# 用正则表达式查出CLeftTicketUrl的值
18+
matchObj = re.search('var CLeftTicketUrl = \'(.*)\'', result, re.M|re.I);
19+
if matchObj:
20+
# 如果有值,替换queryUrl
21+
self.session.queryUrl = matchObj.group(1)
1522
return {
1623
"status": True
17-
}
24+
}

0 commit comments

Comments
 (0)