import random

import requests
import tls_client

session = tls_client.Session(client_identifier='chrome_117')
import json

h = {"authority": "www.spirit.com", "x-dtpc": "8$216560782_634h19vKIAKIMFGTUTKRWPPLDKCSORJAIECKGLH-0e0", "accept": "application/json, text/plain, */*", "cache-control": "no-cache", "content-type": "application/json", "origin": "https://www.spirit.com", "sec-ch-ua-mobile": "?0", "sec-fetch-dest": "empty", "sec-fetch-site": "same-origin", "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkb3RSZXpXZWIiLCJqdGkiOiI1ZDVjMzMwYi0zY2Y5LTk2OGYtYzczMC00YWQzMjQxOGQwNWEiLCJpc3MiOiJkb3RSRVogQVBJIn0.HpPtd8CGO_q68CzE9ZWoWE90DBHijl-oNij-LyWlo4I", "cookie": "userCountryLocation=AR; userGeolocation=-60.05, -26.93; _pxhd=15b0ff658780101e092b98c6aceae11673b227ca11674ff492f70664c1ec63bf:d393e8ff-839b-11ee-a10d-8a5d926cbf1e; _abck=59FF424FECF1548CE4CA3273E2AC3F7F~-1~YAAQJGdNaLYSprOLAQAAUVZg0gq/wtHFjxoACRuTBoFMhvKmaDaRKxymtaN/B0mS6LPXzXzqK3iEzb+eyrCqEkr2JBjBbJptIBRuSN7x9OPpj0LSPlAKCSUuSZp0nYODhXImF5dBYkZfU865128iwvkS+AFD+FmiiXI256Kg4bJUhUcrwcbRqdNnhZHBZyTfnJ8eX/K10NuT2yVPcKudgCbqLXG+xR5RR6s7UIC5X7cy09KtGd7yjuRQIZBwqu1YgOmHNwoRLwtuMydvj1mOrTqZIHthyvf4O2jOSMyUBx+870DuPb5bRR/wW3WfqtXPuRU26CpuqXNuZD65RjBdIy42Yq6qbNFDKcrWJCdwa4rZnsC10A3Lfxg7IoE/QreMPJ1+D5426IaN13A1DJJRvXwChwDDDwiYJw==~0~-1~1700045170; ak_bmsc=16F872B284D7D742D9B440904D6EA8A4~000000000000000000000000000000~YAAQXv4ZuFAAG66LAQAAvtpf0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aEBe4pGhyzmq4TeDQAc2IcYlFG9wWC7OFJBp1Z0+Nt3~1; bm_sv=7441A40BE0D728C8E6CF542453E15853~YAAQXv4ZuCIBG66LAQAA1EJg0hU+T+fSZWalU5WEg8eI7jsbaeHmkUuu+rBtUZ6Swo09x+IkRJD9fiTH6jkQAmWcZiwHIPu3UNWzXmdcAKRLnzHAUHaAB8/zGeRfG7eLeIN10VpaHSHMYQg30ycMV9vkC7oTjGnNfeBxk17d+Qw2vb0i6llEtuVUnKYOlsiznYyjfW2wYSWL2KyWiEsiS/ygNTiVnEuOXISwJDbO0OaZ0u4gM8WfxWrj7B/Tt87r~1; _pxde=565ab764e281018491e165254b15ec4fa4b0dfe3fe89b301a514b42fbcfbce0e:eyJ0aW1lc3RhbXAiOjE3MDAwNDE2MDc0MDB9; _pxvid=d393e8ff-839b-11ee-a10d-8a5d926cbf1e; pxcts=e3e68da1-839b-11ee-948d-0a2043fa075e; _px2=eyJ1IjoiZjFjZDM2MDctM2NkMi00ZGRkLTg1MTQtOGMwZjNjYWYxYzFmIiwidiI6ImQzOTNlOGZmLTgzOWItMTFlZS1hMTBkLThhNWQ5MjZjYmYxZSIsInQiOjE3MDAwNDE5MDczOTksImgiOiJjOWYzOGM4M2U4Nzk0NzI1ZTBkOTkwMzBmYmUxMDg0ODkyOGUwNTQ1MTdhOWRjM2FjOTNhMDcxMjJhNGNkZDIyIn0=", "sec-ch-ua": "\"Google Chrome\";v=\"117\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"117\"", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36", "accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ru;q=0.6", "ocp-apim-subscription-key": "dc6844776fe84b1c8b68affe7deb7916", "pragma": "no-cache", "referer": "https://www.spirit.com/", "sec-ch-ua-platform": "\"macOS\"", "sec-fetch-mode": "cors"}

url = "https://www.spirit.com/api/prod-availability/api/availability/search"
data = {
    "includeWifiAvailability": True,
    "criteria": [
        {
            "stations": {
                "originStationCodes": [
                    "SJC"
                ],
                "destinationStationCodes": [
                    "BNA"
                ],
                "searchDestinationMacs": False,
                "searchOriginMacs": False
            },
            "dates": {
                "beginDate": "2023-11-17",
                "endDate": "2023-11-17"
            },
            "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=(',', ':'))
prox = f'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:{random.randint(10000, 13500)}'
prox = 'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:10395'
prox = 'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:10855'

prox = 'http://user-uni001-region-us-sessid-1058-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'

response = requests.post('http://52.52.23.116/tls/forward',
                        json=dict(url=url,method="POST", data=data, proxy=prox, headers=h, debug=True)
                         )
# response = session.post(url, headers=h, data=data, proxy={
#     # 'http':'http://127.0.0.1:7890',
#     # 'https':'http://127.0.0.1:7890',
#     'http': prox,
#     'https':prox,
# })

print(response.text)
print(response)
