commonOrderRelation.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # 普通订单关联
  2. from airasia.OrderRelationEntity import OrderRelationEntity, PassengerEntity;
  3. import json
  4. import urllib3
  5. import requests
  6. import re
  7. import time;
  8. import random;
  9. from pyquery import PyQuery as pq
  10. from utils.HttpUtils import HttpUtils;
  11. urllib3.disable_warnings()
  12. headers = {
  13. "Host": "member.airasia.com",
  14. "Connection": "keep-alive",
  15. "Upgrade-Insecure-Requests": "1",
  16. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
  17. "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
  18. "Accept-Encoding": "gzip, deflate, br",
  19. "Accept-Language": "zh-CN,zh;q=0.9",
  20. };
  21. session = requests.session();
  22. # session.headers.update(headers);
  23. HttpUtils.get(session, "https://member.airasia.com/login.aspx");
  24. print(session.cookies)
  25. clientHeaders = {
  26. "Host": "ssor.airasia.com",
  27. "Connection": "keep-alive",
  28. "Accept": "application/json",
  29. "Origin": "https://member.airasia.com",
  30. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
  31. "Content-Type": "application/json",
  32. "Referer": "https://member.airasia.com/login.aspx",
  33. "Accept-Encoding": "gzip, deflate, br",
  34. "Accept-Language": "zh-CN,zh;q=0.9",
  35. }
  36. # 获取clientId
  37. session.headers.update(clientHeaders)
  38. clientHtml = HttpUtils.get(session, "https://ssor.airasia.com/config/v2/clients/by-origin");
  39. clientId =json.loads(clientHtml.content.decode()).get("id");
  40. print(clientId)
  41. apiKey = json.loads(clientHtml.content.decode()).get("apiKey");
  42. # 登录参数
  43. loginFoms = {
  44. "username": "luyanan0718@163.com",
  45. "password": "18135237517Lyn"
  46. }
  47. # oeu当前时间戳+r+随机数
  48. optimizelyEndUserId ="oeu"+int(round(time.time() * 1000)).__str__()+"r"+random.random().__str__();
  49. loginHeaders = {
  50. "Host":"ssor.airasia.com",
  51. "Connection":"keep-alive",
  52. "Accept":"application/json",
  53. "Origin":"https://member.airasia.com",
  54. "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36",
  55. "x-api-key":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkFBMDA1TVAiLCJvcmlnaW4iOiJodHRwczovL21lbWJlci5haXJhc2lhLmNvbSIsImlhdCI6MTUyMjA1NTM4MywiZXhwIjoxNTIyMDU4OTgzfQ.RxUhaPfypUeufuP2Yq3mQit4I3opa6LB1Z7zFMy5laU",
  56. "Content-Type":"application/json",
  57. "Referer":"https://member.airasia.com/login.aspx",
  58. "Accept-Encoding":"gzip, deflate, br",
  59. "Accept-Language":"zh-CN,zh;q=0.9",
  60. }
  61. session.headers.update(loginHeaders);
  62. session.headers.setdefault("x-api-key",apiKey);
  63. print(session.headers)
  64. while True:
  65. session.headers.setdefault("Cookie","optimizelyEndUserId="+optimizelyEndUserId+"X-CDN-Geo-Country=CN; X-CDN-Geo-City=BEIJING;currencySelect=CNY; LanguageSelect=en;");
  66. loginHtml = HttpUtils.post(session, "https://ssor.airasia.com/sso/v2/authorization/by-credentials?clientId="+clientId, data=loginFoms)
  67. print(loginHtml.content.decode())
  68. headers = {
  69. "Origin":"https://www.airasia.com",
  70. "Referer":"https://www.airasia.com/en/home.page",
  71. "Accept-Language":"zh-CN",
  72. "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",
  73. "Accept":"application/json",
  74. "content-type":"application/json",
  75. "x-api-key":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkFBMDAxQVAiLCJvcmlnaW4iOiJodHRwczovL3d3dy5haXJhc2lhLmNvbSIsImlhdCI6MTUyMjExNzU4NCwiZXhwIjoxNTIyMTIxMTg0fQ.qjlbeHYjv_9SIDoEMk1GdYL1EWFcDFOE-TG6mX0qIWU",
  76. "Accept-Encoding":"gzip, deflate, br",
  77. "Host":"ssor.airasia.com",
  78. "Connection":"Keep-Alive",
  79. "Cache-Control":"no-cache",
  80. "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",
  81. }
  82. #登录操作
  83. url = "https://ssor.airasia.com/sso/v2/authorization/by-credentials?clientId=AA001AP"
  84. froms = {"username":"luyanan0718@163.com",
  85. "password":"18135237517Lyn"};
  86. session.headers.update(headers);
  87. html = session.post(url,data=froms);
  88. print(html.cookies)
  89. print(html.content.decode())