import json

import tls_client

sess = tls_client.Session(client_identifier='chrome_120', random_tls_extension_order=True)

sess.proxies = {
    'http': 'http://127.0.0.1:8890',
    'https': 'http://127.0.0.1:8890',
}
headers = {
      'pragma': 'no-cache',
      'content-type': 'application/json',
      'origin': 'https://www.spirit.com',
      'cookie': '_px2=eyJ1IjoiYzc1Y2EzMjAtZmI5NS0xMWVlLWFiMGUtMjE0MzJkYTI1YzFiIiwidiI6ImM3YTZjZjhmLWZiOTUtMTFlZS04MDYyLTI5ZjFmOTMwNGEzMCIsInQiOjYyMDIzMzg4MDAwNCwiaCI6ImY5ZjQyY2M0NWQwYjcwMzRhNWRhNTk2N2M2NTc0NTdmMTllMmNkNzkzOWM2NzQ0ZjQ3NThiMTA2NzUwNGU0NTMifQ==; pxcts=c7a6deec-fb95-11ee-8062-70845939060c; _pxvid=c7a6cf8f-fb95-11ee-8062-29f1f9304a30; _abck=C8D1573989B832A386C638D8FE3E9E40~0~YAAQyVQhFwdW1JuOAQAA2dim5AuS9BAu8XE+p5f6yphZfhnNFqtM9TyMVBD7n4NudfwMm3TpBP0ytokyH5l6svHR5MaAfHHbbVf3JdGbSAbGCcOAyTxa2IyJcATCyd2bwgPRE8Gm4ixeQ14gvvCoRHpyOT4sL3NcwBnjQoP2JNhmCu2ql/nKXiAkR+8qHDPnPqW/q6mf5BLSTl+fCR5xl+R+Hpu1Kqm6wjuobK54zg1iAb8h3nNf5wum9NIKH8qtFJ6IplJjdM3XjiuFqig6raR6IkVLTnqnjTCtMb32lKUcmVZACtic/GIl0iP60nckE+C4GCrIIMYr/cKl2R7pyop5owDUXiOQWQzX1xlgIlo6px7mnOHBkSdUiSFpClEmXnCFtODPIXHQDK6yFaiE0MJG+jS6sxWSxQ==~-1~-1~1713236723; _pxhd=d116e2f90e429e5c1ce4a84c8c7080128dc8bdb991bbe635b60f040ffa3b2a3a:c8579aa2-fb95-11ee-b628-93a4e5eb9765; ak_bmsc=EB05DA5F9E5E5FF66C266716665D9553~000000000000000000000000000000~YAAQyVQhF6hV1JuOAQAAotWm5BdU/sn24K/hIYIwIO9PsakZM4V8qC9O6LfoI9b+olaK0Xz0FrF1fboHXZVprxOsenZTSpAbFLR1+v9jPCd3viYUY7w7OBhr+EEgcdXo0IrMVYW0ayFpf1hqMehvrDWOpqir126JKcg+JMruMXg4AXo13HNJgJhRBt6GRNCaTM0qfygXFVGxANeO9zGCW1Q311v0HYW+F3Tjr7nPTgL6C+sYysP9/QGoCjQLVg4BLvAnS7mkoBAiUAUygOHVOd/i2/yyLbV+R6fHV8COyDcBmQHq8pdr6KzIKQkdLN6hDvOa1b3CEgV0D+huYJrf8WsB/+AFuGyS67G2cn43ru+E+yaoeyat6kvXakIrNxeDlvaHY6uTYtmrMA==; bm_sz=3AEA852D0370CBC70BE38B300C573FB9~YAAQyVQhFwhW1JuOAQAA2dim5Bcx+OnkFKpvmLyDVJDTR/uuhiFB8gbhgNVBMRVnimQ7MRnE5OqYl3BoiRXx4usngcCqNaSW82jYtpoK86q1yniI0/JEKAd6c2OeDlY1L0Fkzk/5BW40dhxNDJHpTrma9vjvjslK/BDRGVYpXuMl9taRpnHonjTl8kwQZp3GLz/Y71rIV4UdmI3Tods2zsOSzgMKTf3IjtKBGBtks6FmWibBuwPvnbSS00Ujv4E5MZygyjfCWj+BFGZBgPvXzLnhSQVM01y1cnS3JJ2O8dIpJEOHDQErqWR3MK38OB0eyB0uGF6kpMLsEsMCWSc66QC0ZRGW/3T+UKq0150qatKF7tzCIC8obuzaFtQqRqBSpovtZ+dVgP2McipS04v8RxwD~3488055~3224631; userCountryLocation=US; userGeolocation=-95.9374, 41.2596',
      'authority': 'www.spirit.com',
      'accept-language': 'en-US',
      'x-dtpc': '10$492787436_542h10vNDAFLLHTQHFKVMUIMICENMIBAMBWCDES-0e0',
      'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkb3RSZXpXZWIiLCJqdGkiOiJkOTliYzNkMS04MDk0LTA1Y2QtYTlhMi01NDYwNTY1MzhkNGUiLCJpc3MiOiJkb3RSRVogQVBJIn0.ocBf56aMypXZo9npHD4HEiE9OMrDOP8BXDkK9kPxRnI',
      '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(0x6309092b) XWEB/8555 Flue',
      'accept': 'application/json, text/plain, */*',
      'cache-control': 'no-cache',
      'ocp-apim-subscription-key': 'dc6844776fe84b1c8b68affe7deb7916',
      'referer': 'https://www.spirit.com/'
    }

url = "https://www.spirit.com/api/prod-availability/api/availability/search"
data = {"includeWifiAvailability": True, "criteria": [{"stations": {"originStationCodes": ["DFW"],
                                                                    "destinationStationCodes": ["FLL"],
                                                                    "searchDestinationMacs": False,
                                                                    "searchOriginMacs": False},
                                                       "dates": {"beginDate": "2024-04-24", "endDate": "2024-04-24"},
                                                       "filters": {"filter": "Default"}}],
        "passengers": {"types": [{"type": "ADT", "count": 1}]}, "codes": {"currency": "USD"},
        "fareFilters": {"loyalty": "MonetaryOnly", "types": [], "classControl": 1}, "taxesAndFees": "TaxesAndFees",
        "originalJourneyKeys": [], "originalBookingRecordLocator": None, "infantCount": 0, "birthDates": []}
data = json.dumps(data, separators=(',', ':'))
response = sess.post(url, headers=headers, data=data)

print(response.text)
print(response)
