123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- # 普通订单关联
- from airasia.OrderRelationEntity import OrderRelationEntity, PassengerEntity;
- import json
- import urllib3
- import requests
- import re
- import time;
- import random;
- from pyquery import PyQuery as pq
- from utils.HttpUtils import HttpUtils;
- urllib3.disable_warnings()
- headers = {
- "Host": "member.airasia.com",
- "Connection": "keep-alive",
- "Upgrade-Insecure-Requests": "1",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
- "Accept-Encoding": "gzip, deflate, br",
- "Accept-Language": "zh-CN,zh;q=0.9",
- };
- session = requests.session();
- # session.headers.update(headers);
- HttpUtils.get(session, "https://member.airasia.com/login.aspx");
- print(session.cookies)
- clientHeaders = {
- "Host": "ssor.airasia.com",
- "Connection": "keep-alive",
- "Accept": "application/json",
- "Origin": "https://member.airasia.com",
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
- "Content-Type": "application/json",
- "Referer": "https://member.airasia.com/login.aspx",
- "Accept-Encoding": "gzip, deflate, br",
- "Accept-Language": "zh-CN,zh;q=0.9",
- }
- # 获取clientId
- session.headers.update(clientHeaders)
- clientHtml = HttpUtils.get(session, "https://ssor.airasia.com/config/v2/clients/by-origin");
- clientId =json.loads(clientHtml.content.decode()).get("id");
- print(clientId)
- apiKey = json.loads(clientHtml.content.decode()).get("apiKey");
- # 登录参数
- loginFoms = {
- "username": "luyanan0718@163.com",
- "password": "18135237517Lyn"
- }
- # oeu当前时间戳+r+随机数
- optimizelyEndUserId ="oeu"+int(round(time.time() * 1000)).__str__()+"r"+random.random().__str__();
- loginHeaders = {
- "Host":"ssor.airasia.com",
- "Connection":"keep-alive",
- "Accept":"application/json",
- "Origin":"https://member.airasia.com",
- "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
- "x-api-key":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkFBMDA1TVAiLCJvcmlnaW4iOiJodHRwczovL21lbWJlci5haXJhc2lhLmNvbSIsImlhdCI6MTUyMjA1NTM4MywiZXhwIjoxNTIyMDU4OTgzfQ.RxUhaPfypUeufuP2Yq3mQit4I3opa6LB1Z7zFMy5laU",
- "Content-Type":"application/json",
- "Referer":"https://member.airasia.com/login.aspx",
- "Accept-Encoding":"gzip, deflate, br",
- "Accept-Language":"zh-CN,zh;q=0.9",
- }
- session.headers.update(loginHeaders);
- session.headers.setdefault("x-api-key",apiKey);
- print(session.headers)
- while True:
- session.headers.setdefault("Cookie","optimizelyEndUserId="+optimizelyEndUserId+"X-CDN-Geo-Country=CN; X-CDN-Geo-City=BEIJING;currencySelect=CNY; LanguageSelect=en;");
- loginHtml = HttpUtils.post(session, "https://ssor.airasia.com/sso/v2/authorization/by-credentials?clientId="+clientId, data=loginFoms)
- print(loginHtml.content.decode())
- headers = {
- "Origin":"https://www.airasia.com",
- "Referer":"https://www.airasia.com/en/home.page",
- "Accept-Language":"zh-CN",
- "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299",
- "Accept":"application/json",
- "content-type":"application/json",
- "x-api-key":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkFBMDAxQVAiLCJvcmlnaW4iOiJodHRwczovL3d3dy5haXJhc2lhLmNvbSIsImlhdCI6MTUyMjExNzU4NCwiZXhwIjoxNTIyMTIxMTg0fQ.qjlbeHYjv_9SIDoEMk1GdYL1EWFcDFOE-TG6mX0qIWU",
- "Accept-Encoding":"gzip, deflate, br",
- "Host":"ssor.airasia.com",
- "Connection":"Keep-Alive",
- "Cache-Control":"no-cache",
- "Cookie":"X-CDN-Geo-Country=CN; X-CDN-Geo-City=BEIJING; currencySelect=CNY; LanguageSelect=en;__airasiaga=GA1.2.1362858578.1522117586; __airasiaga_gid=GA1.2.1828054374.1522117586; optimizelyEndUserId=oeu1522117586155r0.9457181034918465; __gads=ID=09f00687f97d333d:T=1522117585:S=ALNI_MafJy5rGNja87OCksyp_r6hsfu6ug; _gali=loginbutton",
- }
- #登录操作
- url = "https://ssor.airasia.com/sso/v2/authorization/by-credentials?clientId=AA001AP"
- froms = {"username":"luyanan0718@163.com",
- "password":"18135237517Lyn"};
- session.headers.update(headers);
- html = session.post(url,data=froms);
- print(html.cookies)
- print(html.content.decode())
|