#
import re

import requests
import tls_client

session = tls_client.Session(client_identifier='chrome_117',
                             header_order=['Host', 'content-type', 'accept', 'accept-language', 'authority',
                                           'cache-control', 'pragma', 'sec-ch-ua', 'sec-ch-ua-mobile',
                                           'sec-ch-ua-platform', 'sec-fetch-dest', 'sec-fetch-mode', 'sec-fetch-site',
                                           'sec-fetch-user', 'upgrade-insecure-requests', 'user-agent']
                             )
# px = 'http://127.0.0.1:7890'
# session.proxies = {
#     'http': px,
#     'https': px,
# }
# session.proxies = {
#     'http': "http://user-uni007-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600",
#     'https': "http://user-uni007-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600",
# }
session.proxies = {
    'http': 'http://127.0.0.1:8890',
    'https': 'http://127.0.0.1:8890',
}
# session.proxies = {
#     'http': 'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:9000',
#     'https': 'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:9000',
# }
#
# session.proxies = {
#     'http': 'http://uni00001_custom_zone_US_sid_67336724_time_5:q39CEBTs5A@us.foxyip.com:7778',
#     'https': 'http://uni00001_custom_zone_US_sid_67336724_time_5:q39CEBTs5A@us.foxyip.com:7778',
# }
# headers = {"Host": "makeabooking.flyscoot.com", "upgrade-insecure-requests": "1", "cache-control": "no-cache", "pragma": "no-cache", "sec-ch-ua": "\"Google Chrome\";v=\"117\", \"Not;A=Brand\";v=\"8\", \"Chromium\";v=\"117\"", "sec-fetch-site": "none", "sec-fetch-user": "?1", "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": "reese84=3:VJ820WHhjme3/crOQaj78A==:eFJPEYy8XcYEaP/atv9fsT5D7ToFdNFTxaa4bwmR90dilu33beyKbfCyJnkdhT9e+5l8jAJb01h63pqt05MhGg9r/5RZejtnfIJAECMnRb6Zz7BEkeLZHIV2vSo0tb0/li9KV0/pG2fQ2hPC4Bf70WMmyNgXLCNy6+xR/VTTLuisf27xMI4qQqlwJOL4ceXIKRg9TJESeDrKT3lq+uTN/nHd5m7bMSe1jU2P7blcGFw3lCBoz9edfjoSXd2/7TxU4XcRvSz0heQxlH5afjWXEN9O/ZdR5HvbXvj8R534nWEpIlsMSF4LFm+ZtDChW+DaIXYCrON88ZAjtRRoGJD+m10v7dwIhz8GE7jqSX6w+COBRVuUw+TolSElhniGECx9ecxrDXK4lenXEBbti9c6qsUW0aDucOXJ7RuH846Cv/wHzWgxDdXfq8d48wUkWiG/CUQcWwjYUB5yQxjS+PZBHw==:199JVZOOdh33meA+GDcpO7MgGYmM8lFo8rd89zsD8XI=; incap_ses_1162_2444946=tHIUBxd4eUOf2aNY70EgEHjtb2UAAAAAV4E0WPMRva8MqaB4iKuE1g==; nlbi_2444946_2147483392=bCBsA6JgUAtev9ZQbmwDOgAAAACEAf4Pzyd7zDA/Owdy7p7I; visid_incap_2444946=yoawIYrdRCqTlkmmJjaoKHjtb2UAAAAAQUIPAAAAAADcMmrcTzpY1NPbHZffXyVR", "authority": "makeabooking.flyscoot.com", "sec-ch-ua-platform": "\"macOS\"", "sec-fetch-dest": "document", "sec-fetch-mode": "navigate", "accept-language": "en-US,en;q=0.9", "sec-ch-ua-mobile": "?0"}

headers ,cookies = ({'Host': 'makeabooking.flyscoot.com', 'accept-language': 'en-US,en;q=0.9', 'authority': 'makeabooking.flyscoot.com', 'cache-control': 'no-cache', 'pragma': 'no-cache', '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': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'none', 'sec-fetch-user': '?1', 'upgrade-insecure-requests': '1', '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'}, {'reese84': '3:4VO5HlaJQFzMu7zyUn+KwQ==:YQxCfIeU7Vb68mzxfd+YJRi4cPOoQ4cARU2EWlnzuQOh1g0wAve6QAKMDwdtfnK3j1OXBAUwJDAAB0GQH6RzxpZVeL+ODQNGgi3zaGxCjV4S2FjuyPdSNlhZnOEVWMcFW37CQRcgUgpMMxSCJmuq8ElkH5g+AeFhqagijk4P2zn1Uk4BQNa987XOb2Mz2F1rVokoK8x5oxevp+Y+an+QghYy2SsVCZ/WHdUQ2dr2OlRBmGldgTEGsHcdVoDJGkwrZW+GDCR6v8NZfpD/j3shpugsgHqG7dASBmblPvQj95hZ+h0+QLVNeAEEPf2kvRqXSl1rNInlIiyymCyIObXe5A1whFKpwt9udBHZzkQ5C0waaNTY1PDUjnRpR84Vve6SqUYNB75V+t1EPyhQ51ipP78303sbK6QJ55WE9NWQ62xjA7+s5MOtrdEPaiMwXFoSIdoUX/G6gQMuroq5Afx0jw==:4Tn2MNEt6I88csuHAey/NFSSbdXfvoovVjknDzxQBak=', 'incap_ses_1001_2444946': 'K3aQBv/582ntO3ynXkTkDcQqcGUAAAAAhgOults9gpnE6iK89JIRLw==', 'nlbi_2444946_2147483392': '/P2hBumSKEVFwqcUbmwDOgAAAAAAP/iwKH8x5Kb1rlNo3LB2', 'visid_incap_2444946': '13N6ErCmQOKo0CCXKgASbsQqcGUAAAAAQUIPAAAAAADMb/Rh65/VO/0hnEZBfNL+'})


cookies = {
   "reese84": "3:Jj3w9QXzDbKT1TirzupAgg==:DYLq/8/43uCXwWu1kM5JWqyL0BtCSQNN9ZybTHXVvLPF57CBs3czCJWQBjMlMUGxdorTeZ448W8ME6U4D9q0vTsZMwNBO9++DhjucAPIovi+E/ZLDb/k5fMq+hcGsZm73rgck+knhW2O8J6EIkfFftSI41gQQtGFOJmqwKlbrot8B3TmvkAVVxDyAJ0W7GylTKyVjBBVQOXHA0idKHfB7nnCzg0TqZ2CmeY7dwZwuGJ61ZLAH5c9dKLNh0VFdT+JcndMWQ87pQE1jmKKXHcqsE8SlTTkfvsHp3Oi2+gds+Q2EEud8LIbbAcN1vhzr+Y7ydInRqyBzIQRvLQ60qGXAsa+NEM8XpPc1KbObc0/VXmfHkBJN5EMmYfu4K3AjXpx3H7DOXvwWzt0+4VFvpkGe6GCPARfJc/TVSWrg4iufcvGxy3FZJbUPj3nd70uLoVOSZBWFyU1tG7johTSpR5XjMFDkaeRWzito7Lb50ClIZw=:v3ujabpEMeL2XH2fp+tQzqeAjzHz2N613MlzyPtKS5Y="


}
cks = []
for k, v in cookies.items():
    cks.append(f'{k}={v}')
headers['cookie'] = '; '.join(cks)
# headers['cookie'] = 'cookie: viewedOuibounceModal=true; loc=RU; hpu=/en; curr=SGD; nlbi_2444926=BQWkQzWxbCxWZUSTgG/1SgAAAADvneO8HD9YrOo1oNJVuImg; visid_incap_2444926=oJ/WridKTLa7YPrulyWXS2xclmUAAAAAQUIPAAAAAACCLIDlOz0pgeJVmV6JeY70; incap_ses_1045_2444926=C5VvLFJn5kUWZTPEGZeADm1clmUAAAAA6CxppBqZeCzHHnjiCLK+Ig==; dtCookie=v_4_srv_-2D37_sn_6V7NGQRV8VSKA62N914MSG3JHNER95LH; rxVisitor=1704352880380B4AUHHBKBA3II224RCL5E2M4ISLU4D9P; dtSa=-; _gcl_au=1.1.1950747451.1704352881; country=RU; visid_incap_3032444=sw8DCT0URdK4TEunjpR3z3BclmUAAAAAQUIPAAAAAACOiqDER1mqI5r9DeEvP3yz; nlbi_3032444=s9E9aPNzKTa4bwgL/g7ELQAAAADTWpFn8pjLhzxo15SN3oGu; incap_ses_1045_3032444=zLxGDOkwmCSZaTPEGZeADnBclmUAAAAADp4s5beS/7/dlVr0WW2gqg==; _fbp=fb.1.1704352881612.117415451; _cls_v=fcec4b38-0fef-4a64-ae2f-e7b99d7bdafd; _cls_s=bb100b55-5bc8-4163-a36b-dc4ddb9bb419:0; __clickidc=170435288295804468; _yjsu_yjad=1704352882.5a8359b1-8306-41e9-8659-21ccd5e9cc51; tfpsi=8514b406-5a16-4d57-a062-8ed6d3448376; nlbi_2444926_2147483392=rHmPdyJDdzi3Z70MgG/1SgAAAAB+QVJwR8LNw2mAp/+EQEgi; __qca=P0-1932161473-1704352882016; _gid=GA1.2.1139298275.1704352891; _ga_C8VV4V6CZR=GS1.2.1704352892.1.0.1704352892.60.0.0; rxvt=1704354693948|1704352880381; dtPC=-37$352880378_811h-vMLBDQOIICMGISGLIKHQFNHMCLPKLKKTS-0e0; ASP.NET_SessionId=pmycaztge0ad1cp2eol02nob; __RequestVerificationToken=O88IieOyYzqgySVFy9GeVXPgV-qFKDib2PXaKH3-pftDOgKPjFGfy3UKlea43Cxi_u-_3R4VG7nGStzt9O5woG5fc44gjHj8a2SXGrIzaxtrINIkigOVgBB9Q9NiZ8N2ZPjwFejyfknB6rXIELTARg2; bfSL8wt6dBrqOezhvfkdarWvtSAaQRRZDvPWtxzeQpCpSLxRnFQ9Fzd5JAsEEjp=638399496971304664; dotrez=\u0021DBwPl7vzzcSKjkj4YfoIV0iGlt0zFrBPzPGbZQw1DJzUMDET3YjABvsEIVvII8N/huRKXUDSLpvcATo=; visid_incap_2444946=1VMmQtu+R6eFhIdhNW9+HH5clmUAAAAAQUIPAAAAAAD/o+fwkbq4oWSSekAPzaRz; nlbi_2444946=sV8MarMqkFreB5ijbmwDOgAAAADZW7IjF6G6cAFibvLftHlX; incap_ses_1045_2444946=HUmKXq9LLxKgdzPEGZeADoFclmUAAAAAVlPho6ykI+keaFO/jLfjDQ==; _ga=GA1.3.2007665498.1704352881; _gid=GA1.3.1139298275.1704352891; _ga=GA1.1.2007665498.1704352881; _ga_GFV545L5B3=GS1.1.1704352880.1.1.1704352898.42.0.0; _ga_C8VV4V6CZR=GS1.3.1704352892.1.1.1704352898.54.0.0; _yoid=aa73af9f-02e3-4242-b756-8c90d4ff7723; _yosid=de340c4c-4976-46f3-9c10-8ffc3e494dc8; startTime=MjAyNC0wMS0wNCAxNToyMTozOQ==; jumpseat_uid=sMZFh4j70N0H7DOnl-nn8i; nlbi_2444946_2147483392=ZILUcBzRwnmEWqsJbmwDOgAAAAAOY9N525ciPScpDjvLyji2; reese84=3:HhrFf7gm5Fr1LQD4RgJWkg==:P5V+FQyHvjEgb9UVFqE5893ekwo34n2HRtOhI7rsuxeQgBxIzteRnRJkL2miDndwoN/9PBZZpxS5qsSzSkfa1pHNSqfmYBgk/FGpGjEIIQpTr+JJ/bjimlF3Js7AcW/TcoYUxe+KTak3zgXVDKi5ia4VET1dW6mcNtAdUqMBTBDnWdGR/sXt9RJrPT2OOu7upNOhoYSeBOZRdrWbBKcQezUn2z0DAucALlJlsk9W/SIbW63r1HgFEmbWuBtmLYO9rAkwjEYCHlZ8tvjxsgux3HsROdGhnK6jNfQD5zitrIZWq7YN+xGd8P1uawBIWe38OrM0I+ah3mNDWd7fJ7hNlOZVpndJ9ohYraa1/wyK8IbvlAUrZK+p+NBSSHD8Faq/Ky3lCceJrOp8r7t0o//nJJTZALRQmAMHBGEjm4XmcDXhf0+qvMNR9CXjQlGm5d9kodmo6+7FRsRoYkL2Uq60NA==:OXMtX3GEVY6fDr7RIS1ss/MNQ7ZuP5eUnbVJ6rV1qQ0=; QSI_HistorySession=https%3A%2F%2Fwww.flyscoot.com%2Fen~1704352895546%7Chttps%3A%2F%2Fmakeabooking.flyscoot.com%2FBook%2FFlight%3Fculture%3Den-SG%26type%3Doneway%26dst1%3DSIN%26ast1%3DADL%26dst2%3DADL%26ast2%3DSIN%26dd%3D2023-12-15%26rd%3Dnull%26adt%3D1%26chd%3D0%26inf%3D0%23~1704352910290'



print(headers)
url = "https://makeabooking.flyscoot.com/Book/Flight?culture=en-SG&type=oneway&dst1=SIN&ast1=ADL&dst2=ADL&ast2=SIN&dd=2023-12-15&rd=null&adt=1&chd=0&inf=0#"
# url = "https://makeabooking.flyscoot.com/Book/Flight"
# params = {
#     "culture": "en-SG",
#     "type": "oneway",
#     "dst1": "SIN",
#     "ast1": "ADL",
#     "dst2": "ADL",
#     "ast2": "SIN",
#     "dd": "2023-12-15",
#     "rd": "null",
#     "adt": "1",
#     "chd": "0",
#     "inf": "0"
# }
# response = session.get(url, headers=headers, params=params, cookies=cookies)
# print(response.url)
# print(response.text)
# print(response)


url = "https://makeabooking.flyscoot.com/manage"


prox = 'http://uni00001_custom_zone_US_sid_67336726_time_5:q39CEBTs5A@us.foxyip.com:7778'
prox = 'http://user-uni007-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
prox = 'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:9000'
prox = 'http://127.0.0.1:8890'
# 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="GET", proxy=prox, debug=True
                                   , allow_redirects=True
                                   ))
response = response.json()
print(response)
print(response['status_code'])
print(response['text'])
print('https://makeabooking.flyscoot.com/'+re.findall('(/_Incapsula_Resource\?SWUDNSA.+?)"', response['text'])[0])

# import requests

#
# request_data = {
#     "service_name": "lcc-tls-forward",
#     "source_url": "http://39.106.6.97:88/svn/develop/lcc-catcher/lcc-tls-forward-1.0.1.jar",
#     "cur_version": "1.0.1",
#     "upgrade": "ON",
#     "force_upgrade": "OFF",
#     "upgrade_method": "serial",
#     "environment": ["prod"]
# }
# request_url = "http://47.102.111.131:8083/api/v1/service/upgrade"
#
# res = requests.post(url=request_url, json=request_data)
# print(res.text)


headers = {
    "authority": "makeabooking.flyscoot.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",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "sec-ch-ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"macOS\"",
    "sec-fetch-dest": "document",
    "sec-fetch-mode": "navigate",
    "sec-fetch-site": "none",
    "sec-fetch-user": "?1",
    "upgrade-insecure-requests": "1",
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}
url = "https://makeabooking.flyscoot.com/manage"
print()