Bladeren bron

线上版本

zhangqf 6 jaren geleden
bovenliggende
commit
6ac1556918
4 gewijzigde bestanden met toevoegingen van 257 en 33 verwijderingen
  1. 3 3
      src/AirasiaWeb.py
  2. 54 20
      src/order/OrderServer.py
  3. 137 10
      src/test/PessHtmlTest.py
  4. 63 0
      src/test/PessHtmlTest2.py

+ 3 - 3
src/AirasiaWeb.py

@@ -91,13 +91,13 @@ class AirasiaWeb(tornado.web.RequestHandler):
                 try:
                     #验证是否Web查询成功(3次重试机会) 
                     _thread.start_new_thread(orderServer.WebQuery,())
-                    _thread.start_new_thread(orderServer.BigQuery,())
+                    #_thread.start_new_thread(orderServer.BigQuery,())
                     time.sleep(1)
                     _thread.start_new_thread(orderServer.WebQuery,())
-                    _thread.start_new_thread(orderServer.BigQuery,())
+                    #_thread.start_new_thread(orderServer.BigQuery,())
                     time.sleep(1)
                     _thread.start_new_thread(orderServer.WebQuery,())
-                    _thread.start_new_thread(orderServer.BigQuery,())
+                    #_thread.start_new_thread(orderServer.BigQuery,())
                     time.sleep(1)
                     _thread.start_new_thread(orderServer.WebQuery,())
                     time.sleep(1)

+ 54 - 20
src/order/OrderServer.py

@@ -125,8 +125,6 @@ class OrderServer():
             seg.cabin = kfsa['cabin']         #舱位等级 EC.特惠 EP.低航费 VF.超值套餐 HF.常飞客 PM.豪华平躺
             if 'E' == seg.cabin:
                 seg.cabin = 'EC'
-            if 'EC' != seg.cabin:
-                self.isContinue = False
             if 'EC' == seg.cabin or 'EP' == seg.cabin:
                 self.luggage = 'PBNO'
             elif 'VF' == seg.cabin or 'HF' == seg.cabin:
@@ -234,7 +232,7 @@ class OrderServer():
 #         if self.oinfo.bigIsOk == False:
 #         self._big_value_lock.release() #web结果锁 开始
     def checkQuery(self):
-        if self.oinfo.bigIsOk and self.oinfo.webIsOk:
+        if self.oinfo.webIsOk:
             return True
         else:
             return False
@@ -475,7 +473,8 @@ class OrderServer():
         agretVal = '' #代理人返程提交字符串
         agfromPrice = self.oinfo.agentFromJson
         agretPrice = self.oinfo.agentRetJson
-        if 'EC' in  self.cabin:
+        #代理人是没有超值套餐 套餐的 我就选择个低价 然后选择 20Kg行李+1份餐食
+        if self.cabin in ('EC','VF'):
             if 'EC' in agfromPrice.keys():
                 agfPrice = agfromPrice['EC']['priceTotal']
                 agfromVal = agfromPrice['EC']['radioValue']
@@ -515,14 +514,25 @@ class OrderServer():
         webretVal = '' #Web官网返程提交字符串
         webfromPrice = self.oinfo.webFromJson
         webretPrice = self.oinfo.webRetJson
-        if self.cabin in webfromPrice.keys():
-            webfPrice = webfromPrice[self.cabin]['priceTotal']
-            webfromVal = webfromPrice[self.cabin]['radioValue']
-        if webretPrice != None:
-            if self.cabin in webretPrice.keys():
-                webrPrice = webretPrice[self.cabin]['priceTotal']
-                webretVal = webretPrice[self.cabin]['radioValue']
-                
+        print(webfromPrice)
+        if self.cabin in 'VF':
+            if self.cabin in webfromPrice.keys():
+                webfPrice = webfromPrice['EC']['priceTotal']
+                webfromVal = webfromPrice['EC']['radioValue']
+            if webretPrice != None:
+                if self.cabin in webretPrice.keys():
+                    webrPrice = webretPrice['EC']['priceTotal']
+                    webretVal = webretPrice['EC']['radioValue']
+        else:
+            if self.cabin in webfromPrice.keys():
+                webfPrice = webfromPrice[self.cabin]['priceTotal']
+                webfromVal = webfromPrice[self.cabin]['radioValue']
+            if webretPrice != None:
+                if self.cabin in webretPrice.keys():
+                    webrPrice = webretPrice[self.cabin]['priceTotal']
+                    webretVal = webretPrice[self.cabin]['radioValue']
+            
+        
         logging.info(self.salt+'Web官网去程:'+str(webfPrice) +'  __'+webfromVal)
         logging.info(self.salt+'Web官网回程:'+str(webrPrice) +'  __'+webretVal)
         
@@ -713,17 +723,37 @@ class OrderServer():
         for row in page.xpath("//div[starts-with(@class,'uccomfortkitpanel-item-selection-form')]/input/@name"):
             passengerData[row] = '0'
             
+        passengerDataABC = []
         #餐食选择
-        passListarts = []
-        for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
-            if '_group_AAXmealCat' in row:
+        if self.ismeals != True:
+            for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
+                passengerData[row] = '0'
+        else:
+            #print(passengerData)
+            passListarts = []
+            passengerDataABC = []       
+            passMeals = []  
+            for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
                 AAXmealCa = row[105:107]+row[136:158]
-                if AAXmealCa not in passListarts:
+                if AAXmealCa not in passListarts and 'mealCat1' in row:
                     passListarts.append(AAXmealCa)
-                    passengerData[row] = '1'
+                    passengerDataABC.append(('drinkcountname','1'))
+                    passengerDataABC.append((row[:158]+'_'+row[136:159]+'1','1'))
+                    passengerDataABC.append((row,'1'))
+                    passMeals.append(row[115:119])
                 else:
-                    passengerData[row] = '0'
-                    
+                    passengerDataABC.append((row,'0'))
+            
+            indexsss = 0;    
+            for row in page.xpath("//div[starts-with(@class,'ucmealpanel-divSelectedMealsContainer')]/input/@name"):
+                if 'SelectedMeal_0' in row:
+                    print(row+'='+passMeals[indexsss])
+                    passengerDataABC.append((row,passMeals[indexsss]))
+                    indexsss = indexsss +1
+                else:
+                    print(row+'=')
+                    passengerDataABC.append((row,''))
+        print(passengerDataABC)
         #行李 PBAB:20Kg PBAC:25Kg PBAD:30Kg PBAF:40Kg
         #self.luggageDict = {20:'PBAB',25:'PBAC',30:'PBAD',40:'PBAF'}
         #行李选择
@@ -781,7 +811,11 @@ class OrderServer():
             passengerData["CONTROLGROUP_OUTERTRAVELER$CONTROLGROUPTRAVELER$PassengerInputTravelerView$DropDownListBirthDateMonth_%d_%d" % (idx, idx)] = passenger.birthday[5:7]
             passengerData["CONTROLGROUP_OUTERTRAVELER$CONTROLGROUPTRAVELER$PassengerInputTravelerView$DropDownListBirthDateMonth_ONTROLGROUPTRAVELER$PassengerInputTravelerView$DropDownListBirthDateYear_%d_%d" % (idx, idx)] = passenger.birthday[:4]
         logging.info(self.salt+'------------------------------------------提交乘机人---:')
-        res = self.session.post('https://booking2.airasia.com/Traveler.aspx', data=passengerData, verify=False,timeout = 60)
+        print(passengerData.items())
+        for row in passengerData:
+            passengerDataABC.append((row,passengerData[row]))
+        print(passengerDataABC)
+        res = self.session.post('https://booking2.airasia.com/Traveler.aspx', data=passengerDataABC, verify=False,timeout = 60)
         logging.info(self.salt+'乘机人提交成功,进入下一步!')
         logging.info(self.salt+str(res.status_code))
         logging.info(self.salt+res.url)

File diff suppressed because it is too large
+ 137 - 10
src/test/PessHtmlTest.py


+ 63 - 0
src/test/PessHtmlTest2.py

@@ -0,0 +1,63 @@
+#-*- coding:utf-8 -*-
+
+from pyquery import PyQuery as pq
+from lxml import etree
+
+f = open('E://ak/testSelectA.html',encoding='utf-8')
+queryHtml = f.read()
+b = pq(queryHtml) 
+page = etree.HTML(queryHtml)
+  
+#餐食选择
+passListarts = []
+
+for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
+    print(row)
+print("=========================================")
+# for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
+#     if 'AAXmealCat' in row:
+#         AAXmealCa = row[105:107]+row[136:158]
+#         print(AAXmealCa)
+#         if AAXmealCa not in passListarts and 'mealCat1' in row:
+#             passListarts.append(AAXmealCa)
+#             print('drinkcountname=1')
+#             print(row[:158]+'_'+row[136:159]+'1=1')
+#             print(row+'=1')
+#             print(row[115:119]+'=1')
+#         else:
+#             print(row+'=0')
+#     if 'AAmealCat' in row:
+#         AAXmealCa = row[105:107]+row[136:158]
+#         print(AAXmealCa)
+#         if AAXmealCa not in passListarts and 'mealCat1' in row:
+#             passListarts.append(AAXmealCa)
+#             print('drinkcountname=1')
+#             print(row[:158]+'_'+row[136:159]+'1=1')
+#             print(row+'=1')
+#             print(row[115:119]+'=1')
+#         else:
+#             print(row+'=0')
+
+passengerDataABC = []       
+passMeals = []  
+for row in page.xpath("//div[starts-with(@class,'ucmealpanel-item-selection-form')]/input/@name"):
+    AAXmealCa = row[105:107]+row[136:158]
+    if AAXmealCa not in passListarts and 'mealCat1' in row:
+        passListarts.append(AAXmealCa)
+        passengerDataABC.append(('drinkcountname','1'))
+        passengerDataABC.append((row[:158]+'_'+row[136:159]+'1','1'))
+        passengerDataABC.append((row,'1'))
+        passMeals.append(row[115:119])
+    else:
+        passengerDataABC.append((row,'0'))
+
+indexsss = 0;    
+for row in page.xpath("//div[starts-with(@class,'ucmealpanel-divSelectedMealsContainer')]/input/@name"):
+    if 'SelectedMeal_0' in row:
+        print(row+'='+passMeals[indexsss])
+        passengerDataABC.append((row,passMeals[indexsss]))
+        indexsss = indexsss +1
+    else:
+        print(row+'=')
+        passengerDataABC.append((row,''))
+print(passengerDataABC)