|
@@ -5,7 +5,6 @@ import requests
|
|
import time
|
|
import time
|
|
import datetime
|
|
import datetime
|
|
import re
|
|
import re
|
|
-import random
|
|
|
|
from lxml import etree
|
|
from lxml import etree
|
|
from pyquery import PyQuery as pq
|
|
from pyquery import PyQuery as pq
|
|
from entity.OrderInfo import OrderInfo,Contact,Passengers,Segments
|
|
from entity.OrderInfo import OrderInfo,Contact,Passengers,Segments
|
|
@@ -24,13 +23,6 @@ class OrderServer():
|
|
self.queryInputJson = {}
|
|
self.queryInputJson = {}
|
|
self.session = requests.session()
|
|
self.session = requests.session()
|
|
self.__VIEWSTATE = ''
|
|
self.__VIEWSTATE = ''
|
|
- cl = call()
|
|
|
|
- self.proxyurl = cl.getProxyIP()
|
|
|
|
- self.proxy_handler = {
|
|
|
|
- 'http': 'http://'+self.proxyurl,
|
|
|
|
- 'https': 'https://'+self.proxyurl,
|
|
|
|
- }
|
|
|
|
- self.session.proxies = self.proxy_handler
|
|
|
|
#请求头
|
|
#请求头
|
|
self.headers = {
|
|
self.headers = {
|
|
'Accept-Encoding': 'gzip',
|
|
'Accept-Encoding': 'gzip',
|
|
@@ -216,6 +208,16 @@ class OrderServer():
|
|
return False
|
|
return False
|
|
#代理人进行登录
|
|
#代理人进行登录
|
|
def AagenLogin(self):
|
|
def AagenLogin(self):
|
|
|
|
+
|
|
|
|
+ #添加代理IP
|
|
|
|
+ cl = call()
|
|
|
|
+ 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")
|
|
res = self.session.get("https://www.airasia.com/my/en/login/travel-agent.page")
|
|
page = etree.HTML(res.text)
|
|
page = etree.HTML(res.text)
|
|
self.logindata['__VIEWSTATE'] = page.xpath("//input[@name='__VIEWSTATE']/@value")[0]
|
|
self.logindata['__VIEWSTATE'] = page.xpath("//input[@name='__VIEWSTATE']/@value")[0]
|
|
@@ -233,6 +235,33 @@ class OrderServer():
|
|
res = self.session.post("https://booking2.airasia.com/LoginAgent.aspx", data=logindata, verify=False, timeout=60)
|
|
res = self.session.post("https://booking2.airasia.com/LoginAgent.aspx", data=logindata, verify=False, timeout=60)
|
|
agentHomeUrl = res.url
|
|
agentHomeUrl = res.url
|
|
logging.info(self.salt+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:
|
|
if 'LoginAgent.aspx' in agentHomeUrl:
|
|
logging.info(self.salt+'一次,登录失败,再次提交一下')
|
|
logging.info(self.salt+'一次,登录失败,再次提交一下')
|
|
res = self.session.post("https://booking2.airasia.com/LoginAgent.aspx", data=self.logindata, verify=False, timeout=60)
|
|
res = self.session.post("https://booking2.airasia.com/LoginAgent.aspx", data=self.logindata, verify=False, timeout=60)
|
|
@@ -315,9 +344,9 @@ class OrderServer():
|
|
logging.info(self.salt+res.url)
|
|
logging.info(self.salt+res.url)
|
|
logging.info(self.salt+str(res.status_code))
|
|
logging.info(self.salt+str(res.status_code))
|
|
#解析代理人查询结果
|
|
#解析代理人查询结果
|
|
- f = open('E://testSelect0.html', 'w',encoding='utf-8')
|
|
|
|
- f.write(res.text.replace('position: fixed; top: 0; left: 0; background: #ffffff; filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7; z-index:9997; width:100%; height:100%;',''))
|
|
|
|
- f.close()
|
|
|
|
|
|
+# f = open('E://testSelect0.html', 'w',encoding='utf-8')
|
|
|
|
+# f.write(res.text.replace('position: fixed; top: 0; left: 0; background: #ffffff; filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7; z-index:9997; width:100%; height:100%;',''))
|
|
|
|
+# f.close()
|
|
self.AgentSearchAnalysis(res.text)
|
|
self.AgentSearchAnalysis(res.text)
|
|
logging.info(self.salt+'解析代理人查询结果完毕')
|
|
logging.info(self.salt+'解析代理人查询结果完毕')
|
|
#解析代理人查询结果
|
|
#解析代理人查询结果
|
|
@@ -360,7 +389,10 @@ class OrderServer():
|
|
break
|
|
break
|
|
if isFlight == False:
|
|
if isFlight == False:
|
|
break
|
|
break
|
|
- originalLowestFare = b(".price span", td).text().replace(',','').replace(' CNY','')
|
|
|
|
|
|
+ pspan = b(".price span", td)
|
|
|
|
+ price = pspan.eq(pspan.length-1).text()
|
|
|
|
+ price = price[0:price.find('CNY')]
|
|
|
|
+ originalLowestFare = price.replace(',','').replace(' ','')
|
|
typsJson = {}
|
|
typsJson = {}
|
|
typsJson['currency'] = 'CNY'
|
|
typsJson['currency'] = 'CNY'
|
|
typsJson['cabin'] = cabinObj[index-1]['code']
|
|
typsJson['cabin'] = cabinObj[index-1]['code']
|
|
@@ -401,7 +433,10 @@ class OrderServer():
|
|
break
|
|
break
|
|
if isFlight == False:
|
|
if isFlight == False:
|
|
break
|
|
break
|
|
- originalLowestFare = b(".price span", td).text().replace(',','').replace(' CNY','')
|
|
|
|
|
|
+ pspan = b(".price span", td)
|
|
|
|
+ price = pspan.eq(pspan.length-1).text()
|
|
|
|
+ price = price[0:price.find('CNY')]
|
|
|
|
+ originalLowestFare = price.replace(',','').replace(' ','')
|
|
typsJson = {}
|
|
typsJson = {}
|
|
typsJson['currency'] = 'CNY'
|
|
typsJson['currency'] = 'CNY'
|
|
typsJson['cabin'] = cabinObj[index-1]['code']
|
|
typsJson['cabin'] = cabinObj[index-1]['code']
|
|
@@ -434,7 +469,10 @@ class OrderServer():
|
|
agfPrice = agfromPrice['EC']['priceTotal']
|
|
agfPrice = agfromPrice['EC']['priceTotal']
|
|
agfromVal = agfromPrice['EC']['radioValue']
|
|
agfromVal = agfromPrice['EC']['radioValue']
|
|
if 'EP' in agfromPrice.keys():
|
|
if 'EP' in agfromPrice.keys():
|
|
- if agfPrice == 0.0 or agfPrice < agfromPrice['EP']['priceTotal']:
|
|
|
|
|
|
+ if agfPrice != 0.0 and agfPrice > agfromPrice['EP']['priceTotal']:
|
|
|
|
+ agfPrice = agfromPrice['EP']['priceTotal']
|
|
|
|
+ agfromVal = agfromPrice['EP']['radioValue']
|
|
|
|
+ if agfPrice == 0.0:
|
|
agfPrice = agfromPrice['EP']['priceTotal']
|
|
agfPrice = agfromPrice['EP']['priceTotal']
|
|
agfromVal = agfromPrice['EP']['radioValue']
|
|
agfromVal = agfromPrice['EP']['radioValue']
|
|
if agretPrice != None:
|
|
if agretPrice != None:
|
|
@@ -442,10 +480,16 @@ class OrderServer():
|
|
agrPrice = agretPrice['EC']['priceTotal']
|
|
agrPrice = agretPrice['EC']['priceTotal']
|
|
agretVal = agretPrice['EC']['radioValue']
|
|
agretVal = agretPrice['EC']['radioValue']
|
|
if 'EP' in agretPrice.keys():
|
|
if 'EP' in agretPrice.keys():
|
|
- if agrPrice == 0.0 or agrPrice < agretPrice['EP']['priceTotal']:
|
|
|
|
|
|
+ if agrPrice != 0.0 and agrPrice > agretPrice['EP']['priceTotal']:
|
|
|
|
+ agrPrice = agretPrice['EP']['priceTotal']
|
|
|
|
+ agretVal = agretPrice['EP']['radioValue']
|
|
|
|
+ if agrPrice == 0.0:
|
|
agrPrice = agretPrice['EP']['priceTotal']
|
|
agrPrice = agretPrice['EP']['priceTotal']
|
|
agretVal = agretPrice['EP']['radioValue']
|
|
agretVal = agretPrice['EP']['radioValue']
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ logging.info(self.salt+'代理人去程:'+str(agfPrice)+' __'+agfromVal)
|
|
|
|
+ logging.info(self.salt+'代理人回程:'+str(agrPrice)+' __'+agretVal)
|
|
|
|
+
|
|
webfPrice = 0.0 #Web官网价格
|
|
webfPrice = 0.0 #Web官网价格
|
|
webrPrice = 0.0 #Web官网价格
|
|
webrPrice = 0.0 #Web官网价格
|
|
webfromVal = '' #Web官网去程提交字符串
|
|
webfromVal = '' #Web官网去程提交字符串
|
|
@@ -459,6 +503,9 @@ class OrderServer():
|
|
if 'EC' in webretPrice.keys():
|
|
if 'EC' in webretPrice.keys():
|
|
webrPrice = webretPrice['EC']['priceTotal']
|
|
webrPrice = webretPrice['EC']['priceTotal']
|
|
webretVal = webretPrice['EC']['radioValue']
|
|
webretVal = webretPrice['EC']['radioValue']
|
|
|
|
+
|
|
|
|
+ logging.info(self.salt+'Web官网去程:'+str(webfPrice) +' __'+webfromVal)
|
|
|
|
+ logging.info(self.salt+'Web官网回程:'+str(webrPrice) +' __'+webretVal)
|
|
|
|
|
|
|
|
|
|
bigfPrice = 0.0 #Big积分价格
|
|
bigfPrice = 0.0 #Big积分价格
|
|
@@ -470,12 +517,16 @@ class OrderServer():
|
|
if bigretPrice != None:
|
|
if bigretPrice != None:
|
|
if 'EC' in bigretPrice.keys():
|
|
if 'EC' in bigretPrice.keys():
|
|
bigrPrice = bigretPrice['EC']['priceTotal']
|
|
bigrPrice = bigretPrice['EC']['priceTotal']
|
|
|
|
+
|
|
|
|
+ logging.info(self.salt+'Big积分去程价:'+str(bigfPrice))
|
|
|
|
+ logging.info(self.salt+'Big积分回程价:'+str(bigrPrice))
|
|
|
|
|
|
if bigfPrice != 0.0:
|
|
if bigfPrice != 0.0:
|
|
#一决雌雄 使用那种方式生单 AGENT_ORDER WEB_ORDER BIG_ORDER
|
|
#一决雌雄 使用那种方式生单 AGENT_ORDER WEB_ORDER BIG_ORDER
|
|
if (bigfPrice + bigrPrice) < (webfPrice + webrPrice) and (bigfPrice + bigrPrice) < (agfPrice + agrPrice):
|
|
if (bigfPrice + bigrPrice) < (webfPrice + webrPrice) and (bigfPrice + bigrPrice) < (agfPrice + agrPrice):
|
|
#Big价格优势
|
|
#Big价格优势
|
|
self.oinfo.modeOrder = 'BIG_ORDER'
|
|
self.oinfo.modeOrder = 'BIG_ORDER'
|
|
|
|
+ logging.info(self.salt+'-----Big价格优势')
|
|
return
|
|
return
|
|
|
|
|
|
self.oinfo.modeOrder = 'AGENT_ORDER'
|
|
self.oinfo.modeOrder = 'AGENT_ORDER'
|
|
@@ -494,7 +545,9 @@ class OrderServer():
|
|
self.oinfo.retRadioValue = agretVal
|
|
self.oinfo.retRadioValue = agretVal
|
|
else:
|
|
else:
|
|
self.oinfo.retRadioValue = agretVal
|
|
self.oinfo.retRadioValue = agretVal
|
|
-
|
|
|
|
|
|
+ logging.info(self.salt+'生单方式:'+self.oinfo.modeOrder)
|
|
|
|
+ logging.info(self.salt+'去:'+self.oinfo.fromRadioValue)
|
|
|
|
+ logging.info(self.salt+'回:'+self.oinfo.retRadioValue)
|
|
#亚航直接走代理人生单
|
|
#亚航直接走代理人生单
|
|
def AgentDirectOrder(self):
|
|
def AgentDirectOrder(self):
|
|
agfPrice = 0.0 #代理人价格
|
|
agfPrice = 0.0 #代理人价格
|