import json
import time

import requests
import tls_client

session = tls_client.Session(client_identifier='chrome_117')
# session = requests.session()
session.proxies = {
    'http': 'http://127.0.0.1:7890',
    'https': 'http://127.0.0.1:7890',
}

proxy = 'http://127.0.0.1:8890'
# proxy = 'http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
headers = {'authority': 'www.southwest.com', 'accept': 'application/json, text/javascript, */*; q=0.01', 'accept-language': 'en,en-US;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/index.html?adultPassengersCount=1&adultsCount=1&departureDate=2023-12-22&departureTimeOfDay=ALL_DAY&destinationAirportCode=LAX&fareType=USD&from=LAS&int=HOMEQBOMAIR&originationAirportCode=LAS&passengerType=ADULT&promoCode=&reset=true&returnDate=&returnTimeOfDay=ALL_DAY&to=LAX&tripType=oneway&validate=true', 'sec-ch-ua': '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"', '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 (Linux; Android 12; SAMSUNG SM-G9750) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/22.1 Chrome/111.0.5563.116 Mobile Safari/537.36', 'x-api-key': 'l7xx944d175ea25f4b9c903a583ea82a1c4c', 'x-app-id': 'air-booking', 'x-channel-id': 'southwest', 'ee30zvqlwf-f': 'A0fgeoGMAQAAMhGp7GfXQyVhtrSCZjpMMwdrE6BUVu1D2srliX6_5xoDiB0NARf3iT0AAAAAAAAAAAAAAAAAAA==', 'ee30zvqlwf-b': 'uewgbn', 'ee30zvqlwf-c': 'AGDddoGMAQAAg4nMuZSsxAZ7qaEYamlgMXF5T7BFw31sIXmOzgrOkrBI9VmM',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Yk3yB6woCkJJ_7ShYMJRFKMc5E2Cy4_rE5mQKiLZJ1uzAwcf_gkalEcLFormwiOn4yhWKNCZO9M-9IhcbLV35xYVuQZ_X1p4ZyeuogqqYnT7diXMld=_HEfXPfgNa7loXTRzT9DrfKxP-y6Re7-INzVpTsp1U_dc4ub832iQNkOImdUEmpUGNnfRrS8Qrs4RULcMa2HJYn6=9x2TZ9c3kBgD_zoFSArml3p2b7JpjlGV7iaHga88EgVU4bz1x=4tbXTLa7J1Gz7=JFGm-VAfBn-6n7YNiVxVrxcLB7q-qsEdVS=ePQ72mr4lzK5JTzMBaHuyawzRmIE9b7qj9NQ3mPzff1P6OOfTsz28ba3t5BAvayEv1oyUZHcn-zmk2cGP1a6Y3eGpBd7l6wz91r_vvuDtpSLYZUjZPHsfwRi2J3DZRH=J52oIgUlIx6X8X481UlmDCsCYGjGexYGoVc7GAqpPLD8Ep98dXPe9lpQfVmievoquNhIV72KAxLDfKaiMeW1EXtKHzI1X__KwOojuY9ZlUshXkisE4RND27dq1XY5clMXyfJioqNDKJqRrP9mrBcuvRnfV9YVQxAynyDXQn4ddd5aRtE9RFY1xQ1fm8ns2jlmve-ZSgI2xw24bRm8_FYiN83DJ-HXykkX4-r75zeTbdaWn_HldBFcHASPSz6ZmwU3PkekQYhW-23f-WystRbpfwv5wAuuwZY_vbFmhL88vGfzcaYgWj8jYnWOUi6a59RQpRKfcO_cMN2ZHDRIAToJTDxUQ91YYhft7P=hDy2ZrL_5qMS1Ldm8r1=oOIQ1fWtHqZKB8Dghn8aw7ealKFsgCdb6uMKTwV4u1=Z7'}



while True:
    url = "https://www.southwest.com/api/air-booking/v1/air-booking/page/air/booking/shopping"
    data = {
        "originationAirportCode": "LAS",
        "destinationAirportCode": "LAX",
        "departureDate": "2023-12-03",
        "departureTimeOfDay": "ALL_DAY",
        "returnTimeOfDay": "ALL_DAY",
        "adultPassengersCount": "1",
        "tripType": "oneway",
        "fareType": "USD",
        "passengerType": "ADULT",
        "adultsCount": "1",
        "int": "HOMEQBOMAIR",
        "reset": "true",
        "returnDate": "",
        "application": "air-booking",
        "site": "southwest"
    }
    #
    # # session = requests.Session()
    #
    # 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, headers=headers, method="POST", data=json.dumps(data), proxy=proxy,
                                       debug=True
                                       , allow_redirects=True
                                       ))
    status_code = response.json()['status_code']
    text = response.json()['text']
    print(status_code)
    print(text)
    time.sleep(1)
