From e2e249621b9fe5e790d8511084eff1322cdc98c4 Mon Sep 17 00:00:00 2001 From: Renzhi Date: Tue, 31 Dec 2019 22:43:11 +0800 Subject: [PATCH] check target type is string before doing regex match --- inter/LiftTicketInit.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/inter/LiftTicketInit.py b/inter/LiftTicketInit.py index fa61f187..7559c894 100644 --- a/inter/LiftTicketInit.py +++ b/inter/LiftTicketInit.py @@ -15,10 +15,11 @@ def reqLiftTicketInit(self): # 获取初始化的结果 result = self.session.httpClint.send(urls) # 用正则表达式查出CLeftTicketUrl的值 - matchObj = re.search('var CLeftTicketUrl = \'(.*)\'', result, re.M|re.I); - if matchObj: - # 如果有值,替换queryUrl - self.session.queryUrl = matchObj.group(1) + if isinstance(result, str): + matchObj = re.search('var CLeftTicketUrl = \'(.*)\'', result, re.M|re.I) + if matchObj: + # 如果有值,替换queryUrl + self.session.queryUrl = matchObj.group(1) return { "status": True }