zhangqf 6 years ago
parent
commit
4180349b5d

+ 3 - 1
src/AirasiaWeb.py

@@ -27,6 +27,7 @@ class AirasiaWeb(tornado.web.RequestHandler):
     def post(self):
         param = self.request.body.decode('utf-8')
         logging.info('生单数据:'+param)
+        print('生单数据:'+param)
         prarm = json.loads(param)
         try:
             _thread.start_new_thread(self.akorder,(prarm,))
@@ -156,4 +157,5 @@ if __name__ == '__main__':
     #绑定一个监听端口
     app.listen(8888)
     #启动web程序,开始监听端口的连接
-    tornado.ioloop.IOLoop.current().start()
+    tornado.ioloop.IOLoop.current().start()
+    print('-----------系统启动完毕------------------')

+ 17 - 32
src/order/OrderServer.py

@@ -11,6 +11,7 @@ from entity.OrderInfo import OrderInfo,Contact,Passengers,Segments
 from utils.CallbackOrderUtils import CallbackOrderUtils as call
 from query.AkWebQuery import AkWebQuery
 from query.AkBigQuery import AkBigQuery
+from imghdr import test_webp
 urllib3.disable_warnings()
 import logging
 
@@ -211,7 +212,7 @@ class OrderServer():
         
         #添加代理IP
         cl = call()
-        proxyurl = cl.getProxyIP()
+        proxyurl = cl.getProxyFixedIP()
         proxy_handler = {
             'http': 'http://'+proxyurl,
             'https': 'https://'+proxyurl,
@@ -236,32 +237,6 @@ class OrderServer():
         agentHomeUrl = res.url
         logging.info(self.salt+res.url)
         
-        if 'err504' in agentHomeUrl:
-            proxyurl = cl.getProxyIP()
-            proxy_handler = {
-                'http': 'http://'+proxyurl,
-                'https': 'https://'+proxyurl,
-            }
-            self.session.proxies = proxy_handler
-            logging.info(self.salt+'前一个质量不高IP:'+proxyurl)
-            res = self.session.get("https://www.airasia.com/my/en/login/travel-agent.page")
-            page = etree.HTML(res.text)
-            self.logindata['__VIEWSTATE'] = page.xpath("//input[@name='__VIEWSTATE']/@value")[0]
-            self.__VIEWSTATE = self.logindata['__VIEWSTATE']
-            logging.info(self.salt+'__VIEWSTATE:'+self.__VIEWSTATE)
-            
-            logindata = {
-                "__EVENTARGUMENT": "",
-                "__EVENTTARGET": "ControlGroupLoginAgentView$AgentLoginView$LinkButtonLogIn",
-                "ControlGroupLoginAgentView$AgentLoginView$TextBoxUserID": "CNTRIPTOPK_ADMIN",
-                "ControlGroupLoginAgentView$AgentLoginView$PasswordFieldPassword": "Tripto123",
-                "pageToken": "",
-                "TimeZoneDiff": "480"
-            }
-            res = self.session.post("https://booking2.airasia.com/LoginAgent.aspx", data=logindata, verify=False, timeout=60)
-            agentHomeUrl = res.url
-            logging.info(self.salt+res.url)
-        
         if 'LoginAgent.aspx' in agentHomeUrl:
             logging.info(self.salt+'一次,登录失败,再次提交一下')
             res = self.session.post("https://booking2.airasia.com/LoginAgent.aspx", data=self.logindata, verify=False, timeout=60)
@@ -523,11 +498,21 @@ class OrderServer():
                 
         if bigfPrice != 0.0:        
             #一决雌雄  使用那种方式生单  AGENT_ORDER WEB_ORDER BIG_ORDER
-            if (bigfPrice + bigrPrice) < (webfPrice + webrPrice) and (bigfPrice + bigrPrice) < (agfPrice + agrPrice):
-                #Big价格优势
-                self.oinfo.modeOrder = 'BIG_ORDER'
-                logging.info(self.salt+'-----Big价格优势')
-                return
+            bigp = bigfPrice + bigrPrice
+            webp = webfPrice + webrPrice
+            agp  = agfPrice + agrPrice
+            if webp != 0.0:
+                if bigp < webp and bigp < webp:
+                    #Big价格优势
+                    self.oinfo.modeOrder = 'BIG_ORDER'
+                    logging.info(self.salt+'-----Big价格优势')
+                    return
+            else:
+                if bigp < agp:
+                    #Big价格优势
+                    self.oinfo.modeOrder = 'BIG_ORDER'
+                    logging.info(self.salt+'-----Big价格优势')
+                    return
         
         self.oinfo.modeOrder = 'AGENT_ORDER'
         #接下来是官网与代理的对决

+ 7 - 7
src/query/AkBigQuery.py

@@ -24,14 +24,14 @@ class AkBigQuery:
         retJson = {}
         isOk = True
         session = requests.session()
-        logging.info(salt+"|queryUrl:"+queryUrl)
-        logging.info(salt+"|tripType:"+str(self.tripType))
-        logging.info(salt+"|flightList:"+str(self.flightList))
-        logging.info(salt+"|retFlights:"+str(self.retFlights))
-        logging.info(salt+"|fxRate:"+str(self.fxRate))
-        logging.info(salt+"|queryInputJson:"+str(self.queryInputJson))
+#         logging.info(salt+"|queryUrl:"+queryUrl)
+#         logging.info(salt+"|tripType:"+str(self.tripType))
+#         logging.info(salt+"|flightList:"+str(self.flightList))
+#         logging.info(salt+"|retFlights:"+str(self.retFlights))
+#         logging.info(salt+"|fxRate:"+str(self.fxRate))
+#         logging.info(salt+"|queryInputJson:"+str(self.queryInputJson))
         res = session.post(queryUrl, headers=headers, json=self.queryInputJson)
-        logging.info(salt+"|retJson:"+res.text)
+        #logging.info(salt+"|retJson:"+res.text)
         json_str = json.loads(res.text)
         if 200 == json_str['status']:
             fromSegments = json_str['attachment']['fromSegments']

+ 8 - 8
src/query/AkWebQuery.py

@@ -23,16 +23,16 @@ class AkWebQuery:
         retJson = {}
         isOk = True
         session = requests.session()
-        logging.info(salt+"|queryUrl:"+queryUrl)
-        logging.info(salt+"|tripType:"+str(self.tripType))
-        logging.info(salt+"|flightList:"+str(self.flightList))
-        logging.info(salt+"|retFlights:"+str(self.retFlights))
-        logging.info(salt+"|fxRate:"+str(self.fxRate))
-        logging.info(salt+"|queryInputJson:"+str(self.queryInputJson))
+#         logging.info(salt+"|queryUrl:"+queryUrl)
+#         logging.info(salt+"|tripType:"+str(self.tripType))
+#         logging.info(salt+"|flightList:"+str(self.flightList))
+#         logging.info(salt+"|retFlights:"+str(self.retFlights))
+#         logging.info(salt+"|fxRate:"+str(self.fxRate))
+#         logging.info(salt+"|queryInputJson:"+str(self.queryInputJson))
         res = session.post(queryUrl, headers=headers, json=self.queryInputJson)
         #print(res.status_code)
-        logging.info(salt+"|retJson:"+res.text)
-        print(res.text)
+        #logging.info(salt+"|retJson:"+res.text)
+        #print(res.text)
         json_str = json.loads(res.text)
         if 200 == json_str['status']:
             fromSegments = json_str['attachment']['fromSegments']

+ 28 - 0
src/test/DailiTEst.py

@@ -0,0 +1,28 @@
+#-*- coding:utf-8 -*-
+
+import urllib3
+import requests
+
+urllib3.disable_warnings()
+
+session = requests.session()
+
+#请求头
+headers = {
+    'Accept-Encoding': 'gzip',
+    "Content-Encoding": "gzip, deflate, sdch",
+    "Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6",
+    "Upgrade-Insecure-Requests": "1",
+    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
+}
+session.headers.update(headers)
+
+proxyurl = 'pc316w:pc316w@101.226.179.96:888'
+proxy_handler = {
+    'http': 'http://'+proxyurl,
+    'https': 'https://'+proxyurl,
+}
+session.proxies = proxy_handler
+res = session.get("https://www.airasia.com/my/en/login/travel-agent.page")
+
+print(res.text)

File diff suppressed because it is too large
+ 13 - 2
src/utils/CallbackOrderUtils.py