import random

import requests
import tls_client

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

headers = {"authority": "booking.flyfrontier.com",
           "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
           "accept-language": "en-US,en;q=0.9",
           "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",
           "cookie": '_gcl_au=1.1.19136717.1701421425; _uetsid=8848d5e0902811ee86afbbbf17c51ed6; _uetvid=8848f420902811ee8161cf4462ff114d; _gid=GA1.2.1912190365.1701421426; _ga=GA1.1.1638578950.1701421426; _rdt_uuid=1701421425738.dd458a21-21bf-480c-969a-9bfc11c9aa48; wisepops_visits=%5B%222023-12-01T09%3A03%3A45.329Z%22%5D; pxcts=8901436c-9028-11ee-b437-0e393bfed68a; _pxvid=89013846-9028-11ee-b437-e84770752d96; _px2=eyJ1IjoiODc1ZGIxMjAtOTAyOC0xMWVlLTk0MDEtMTk3YzNlMTcxMzM0IiwidiI6Ijg5MDEzODQ2LTkwMjgtMTFlZS1iNDM3LWU4NDc3MDc1MmQ5NiIsInQiOjYyMDIzMzg4MDAwNCwiaCI6ImY1MTNhZjAyYTVlYmZlODFjODFlNjk2YWEyNWM2OWJjNzVhNGE4Yzc3NTA4MWRlMWU5OTFiYTY2YzliNTRhMWUifQ==; _up=1.2.189366662.1701421429; _fbp=fb.1.1701421441538.52436412; _tt_enable_cookie=1; _ttp=l1Aeh5a0ZbtNcwEfGckRaa6atkS; _pin_unauth=dWlkPVpXSmxNV0ptTm1VdE1EQmhaaTAwWkdJNUxXSXhOemd0TVRKbU1EQmpZamd4TjJSbQ; ORA_FPC=id=10cc0c64-522d-4ed2-8a00-203101d0550c; WTPERSIST=; wisepops_session=%7B%22arrivalOnSite%22%3A%222023-12-01T09%3A03%3A45.329Z%22%2C%22mtime%22%3A1701421456739%2C%22pageviews%22%3A1%2C%22popups%22%3A%7B%22429858%22%3A0%7D%2C%22bars%22%3A%7B%7D%2C%22sticky%22%3A%7B%7D%2C%22countdowns%22%3A%7B%7D%2C%22src%22%3Anull%2C%22utm%22%3A%7B%7D%2C%22testIp%22%3Anull%7D; wisepops=%7B%22csd%22%3A1%2C%22popups%22%3A%7B%22429858%22%3A%7B%22dc%22%3A1%2C%22d%22%3A1701421456739%2C%22cl%22%3A1%7D%7D%2C%22sub%22%3A0%2C%22ucrn%22%3A83%2C%22cid%22%3A%2278471%22%2C%22v%22%3A4%2C%22bandit%22%3A%7B%22recos%22%3A%7B%7D%7D%7D; _ga_P2WLKWBNNW=GS1.1.1701421425.1.0.1701421482.3.0.0'
           }


url = "https://booking.flyfrontier.com/Flight/InternalSelect?o1=DEN&d1=LAS&dd1=2023-11-30&ADT=1&umnr=false&mon=true"
# cookies = {
#     "_gcl_au": "1.1.2038837281.1701324034",
#     "_uetsid": "c6875dc08f4511eeb3f7f11ab8fb304b",
#     "_uetvid": "c68744708f4511ee9f855353f2975545",
#     "_ga_P2WLKWBNNW": "GS1.1.1701324034.1.0.1701324034.60.0.0",
#     "_pxvid": "c6bac446-8f45-11ee-b7c5-4cd9d74b34e4",
#     "pxcts": "c6bad222-8f45-11ee-b7c7-9188a58ea7b9",
#     "_rdt_uuid": "1701324037158.0c605987-7286-4f74-a141-93c7f6b757b7",
#     "_ga": "GA1.2.995783592.1701324034",
#     "_gid": "GA1.2.1839129764.1701324037",
#     "_gat_UA-2678252-1": "1",
#     "_fbp": "fb.1.1701324037193.549723665",
#     "wisepops_visits": "%5B%222023-11-30T06%3A00%3A34.022Z%22%5D",
#     "_px2": "eyJ1IjoiYzU2N2U1YTAtOGY0NS0xMWVlLWJiMjktZWRhODRhOGNlZTE0IiwidiI6ImM2YmFjNDQ2LThmNDUtMTFlZS1iN2M1LTRjZDlkNzRiMzRlNCIsInQiOjYyMDIzMzg4MDAwNywiaCI6ImQwZmE3YzczYjhhOGNmZDRlNDA0OTk0ZDc2OWI0ZGQxYjRlMDY4ZWZiMmY1MTZlNjkyNDA4ODdiNTk5NWQyNzcifQ==",
#     "_pin_unauth": "dWlkPVpEZzRZemN5WWprdE5qa3hOaTAwTWpFMExXRXhOVEV0TnprME5XWTVZbUppWVRNNA",
#     "_tt_enable_cookie": "1",
#     "_ttp": "eQZSU6A_ffGFgKv6WAToqiayZd_",
#     "_up": "1.2.169746835.1701324038",
#     "wisepops": "%7B%22csd%22%3A1%2C%22popups%22%3A%7B%22429858%22%3A%7B%22dc%22%3A1%2C%22d%22%3A1701324039219%7D%7D%2C%22sub%22%3A0%2C%22ucrn%22%3A50%2C%22cid%22%3A%2278471%22%2C%22v%22%3A4%2C%22bandit%22%3A%7B%22recos%22%3A%7B%7D%7D%7D",
#     "wisepops_session": "%7B%22arrivalOnSite%22%3A%222023-11-30T06%3A00%3A34.022Z%22%2C%22mtime%22%3A1701324039219%2C%22pageviews%22%3A1%2C%22popups%22%3A%7B%22429858%22%3A0%7D%2C%22bars%22%3A%7B%7D%2C%22sticky%22%3A%7B%7D%2C%22countdowns%22%3A%7B%7D%2C%22src%22%3Anull%2C%22utm%22%3A%7B%7D%2C%22testIp%22%3Anull%7D"
# }
# cks = []
# for k, v in cookies.items():
#     cks.append(f'{k}={v}')
# headers['cookie'] = '; '.join(cks)
# headers['cookie'] = '_gcl_au=1.1.844575581.1700477194; _ga=GA1.1.705703545.1700477194; _pxvid=128f1e30-8792-11ee-b443-7061c4ff223f; pxcts=128f28dc-8792-11ee-b443-4e8857f971f4; _uetsid=129d89b0879211ee977771ce32cb65b6; _uetvid=129db280879211ee860d19abd0f03584; wisepops_visits=%5B%222023-11-20T10%3A46%3A33.550Z%22%5D; _tt_enable_cookie=1; _ttp=SUWxt4jqEaMrt1QTUoALn84Sjv4; _pin_unauth=dWlkPU5USXhPREF3WXpndE5qRTBOaTAwTW1aaUxUZ3hNR0V0Wm1NM05tRmxaalJtTTJVMg; _up=1.2.1708435651.1700477197; ORA_FPC=id=c98a5e29-4762-4b94-8d64-abd94c3da5d9; WTPERSIST=; wisepops=%7B%22csd%22%3A1%2C%22popups%22%3A%7B%22429858%22%3A%7B%22dc%22%3A1%2C%22d%22%3A1700477197690%7D%7D%2C%22sub%22%3A0%2C%22ucrn%22%3A36%2C%22cid%22%3A%2278471%22%2C%22v%22%3A4%2C%22bandit%22%3A%7B%22recos%22%3A%7B%7D%7D%7D; wisepops_session=%7B%22arrivalOnSite%22%3A%222023-11-20T10%3A46%3A33.550Z%22%2C%22mtime%22%3A1700477197690%2C%22pageviews%22%3A1%2C%22popups%22%3A%7B%22429858%22%3A0%7D%2C%22bars%22%3A%7B%7D%2C%22sticky%22%3A%7B%7D%2C%22countdowns%22%3A%7B%7D%2C%22src%22%3Anull%2C%22utm%22%3A%7B%7D%2C%22testIp%22%3Anull%7D; _px2=eyJ1IjoiMTIzNzQwZDAtODc5Mi0xMWVlLWI5MDYtMTc3Y2I5NjUwMjE0IiwidiI6IjEyOGYxZTMwLTg3OTItMTFlZS1iNDQzLTcwNjFjNGZmMjIzZiIsInQiOjE3MDA0Nzc3NjA1MjcsImgiOiI0YWU4NDRjZTgyYmQ0ZWVhYmEzMjkyZjdiYTRhMWE2YzA2M2M4ZTA0YmQ3NzU2MTRiNWY5ZTcyNWY2MzA0MTRkIn0=; _ga_P2WLKWBNNW=GS1.1.1700477193.1.1.1700477480.58.0.0'

prox = 'http://user-uni001-region-us-sessid-1114-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
prox = f'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:{random.randint(10000, 13500)}'
# prox = 'http://user-uni001-region-us-sessid-4909-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
# prox = 'http://74.48.159.194:33080'
# print(prox)


for i in range(20):
    # prox = 'http://127.0.0.1:8890'
    # url = "http://httpbin.org/ip"
    response = requests.post('http://52.52.23.116/tls/forward',
    # response = requests.post('http://127.0.0.1:58000/tls/forward',

                             json=dict(url=url, method="GET", proxy=prox, headers=headers, debug=True,
                                       allow_redirects=True
                                       )
                             )

    # print(response.json())

    print(response.json()['status_code'])
    print('FlightData' in response.json()['text'])
