import requests
import json
import tls_client

session = tls_client.Session(client_identifier='chrome_117', random_tls_extension_order=True)
proxy = 'http://127.0.0.1:7890'
session.proxies = {
    'http': proxy,
    'https': proxy,
}
headers = {
    "authority": "www.southwest.com",
    "accept": "application/json, text/javascript, */*; q=0.01",
    "accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ru;q=0.6",
    "cache-control": "no-cache",
    "content-type": "application/json",
    "origin": "https://www.southwest.com",
    "pragma": "no-cache",
    "referer": "https://www.southwest.com/air/booking/select.html?int=HOMEQBOMAIR&adultPassengersCount=1&departureDate=2023-09-21&destinationAirportCode=LAX&fareType=USD&originationAirportCode=LAS&passengerType=ADULT&promoCode=&returnDate=2023-09-24&tripType=roundtrip&from=&to=&adultsCount=1&departureTimeOfDay=ALL_DAY&reset=true&returnTimeOfDay=ALL_DAY",
    "sec-ch-ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"macOS\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
    "x-api-key": "l7xx944d175ea25f4b9c903a583ea82a1c4c",
    "x-app-id": "air-booking",
    "x-channel-id": "southwest",

}

# https://www.southwest.com/assets/app/scripts/swa-common.js
headers.update(
    {'ee30zvqlwf-f': 'A9whqoaMAQAAnqC9oPls74bbCXnuBToke--BT6k5EG0k7XT28xJ4BCOypnVCAWjqBAcAAAAAAAAAAAAAAAAAAA==',
     'ee30zvqlwf-b': 'bewtdv', 'ee30zvqlwf-c': 'ACBhpoaMAQAAxzcTCrt6zDxyx5tBAJN1CDRAG950vLXdBCKbiG8gRXmel-xb',
     'ee30zvqlwf-d': 'ABaAhIDBCKGFgQGAAYIQgISigaI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=21tfJ0P8lJBAm0g363W3ViEjjj3ebI6sKeOpixhGf71pN-a5Um6UWaJRXJSKyMPI6Gj-LQqr8UfxLatINMeagt_SuZ8YsK8AXO8gmF0tHZZgD3kUCi-r3tMeQ7eiUyXbmL_=bkG8fQyNDS2pkc6gew-NzOPUiKW5CrFuIcAyWWm9XJ8rlrL2Pi8AqNvN8rA=h-PyU9sOjFnoEj_J6-zYDtDC3HMhWfaSwX7O2z-q0z_ab5z=kxpLvq0ocVSAoFSWbgMFORqL=iQoIJwWg=THBtQvDsfRipmm7ZUmRVYqdYk7UHLKi75VvTdFqlX9wjn9UdrEFBMXtPCfW3B0ZB0o6-2_=mPLOeB=MbBkF5yxNjWcO6wOshgUdeWi80-Kj7lsveW5BWOuj3fFjEeS3W=g25JJoiPrEGvZMktPNfhvnHDKJI19OKpgPwXbTuDOZ1SNvfsBuOHfrX2O1pxTP2IlnH2wVtguMFFpIBeJ706hzarvZu7HBMnjk9Y6jZKG9m55cqkN6CxNk3jqPj23v5K=kyBnK_HgJJU20N9qATuvR2rfQFOPfZ3fLmBj_ZjId=P0yjsuTMqg=priz1FiJBJmPvukyHDTHI1t0pxgrcf6LJ9EHiP6-pEBSBzXbx0RuHIEUa-ldhYyTamBIrlOVus=q7-BJosI2Nfr8ln3C_rLWqWnT=iu6SKeOSKtXOGzr-DtScaNAMCZP8mzStAs6F3kPVenam=AwFr_CegHE3gR-haXREK5o-c_h1zzOjcx3wWCS=Ah_Eu-DzenUYLwNZfzwlbg83Nsmsnu1EDnFUiwfWQlPllCxYzWevLgoByFvisS0XC8J3mh',
     'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x6309001c) XWEB/8391'}

)
url = "https://www.southwest.com/api/air-booking/v1/air-booking/page/air/booking/shopping"
data = {
    "adultPassengersCount": "1",
    "adultsCount": "1",
    "departureDate": "2023-12-22",
    "departureTimeOfDay": "ALL_DAY",
    "destinationAirportCode": "LAX",
    "fareType": "USD",
    "from": "",
    "int": "HOMEQBOMAIR",
    "originationAirportCode": "LAS",
    "passengerType": "ADULT",
    "promoCode": "",
    "reset": "true",
    "returnDate": "2023-08-24",
    "returnTimeOfDay": "ALL_DAY",
    "to": "",
    "tripType": "roundtrip",
    "application": "air-booking",
    "site": "southwest"
}
data = json.dumps(data, separators=(',', ':'))
response = session.post(url, headers=headers, data=data)

print(response.text)
print(response)
