jonathanjordan21 commited on
Commit
5a8e0c2
·
verified ·
1 Parent(s): 9473ef1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -18,6 +18,18 @@ cookie_string = """userlang=en; session_access_token=eyJraWQiOiIwMFhlOVdGODNHbDJ
18
  session_refresh_token=eyJraWQiOiJpMXVPV2drM1Q1dlBmb1BDczJCODVBSm1obW40Nk5ETCJ9.eyJhdWQiOiJ0aWtldC5jb20vcnQiLCJzdWIiOiI2NzYxMjM5NzkzZGNjODJhNWZmNDE1YTMiLCJuYmYiOjE3MzQ0MTkzNTEsImlzcyI6Imh0dHBzOi8vd3d3…ZHkxNFdfjWxz3veFZHYRN8GhkWFe5UJte_yvcewVVvR7e5qVs5J_JbVzIZaDv1Rb39SEVHcb3ZUKoq5eOTaSKpCm7YA;
19
  cf_clearance=txA3F6mlyQt1XzsIY6OxCM86BmMswcmyX8XmPpOULc0-1734421561-1.2.1.1-Dqk4hE0_.4Y5OQkD6LPXGgC3Z0dfzvirBDr.209VtndL06wBVt.xUN1EGdQ7LBL50dIR_rE1y58KndTzS832O5lp4Iz9KoR8BIBVWX7tbDLfgaF1sABo4rsb_l_mmThS56EODLjin3QLZAC8RMZ10DFAGI6xgqsBv75uQjx.7Tduj3LbjPfjq14T4V6N6uwKn9Hn05t79vC.z_buGQYSZK2qTKcn3tA.pCQqOMG7RjVcffVbIPFWNOMfuYNrK5GC3mh.uERzdAw2FoOY4ddSDR4biGYxxwMDxI0A5v.DBdp4jgUL_BY5YSWwSfaS89ymKXj9gyplQ.FiRG6LmLRT_g"""
20
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @app.get("/")
22
  def greet_json():
23
  return {"Hello": "World!"}
@@ -38,22 +50,10 @@ async def get_flights(
38
  returnDate: str = "2024-12-21",
39
  # enableVI=true
40
  ):
41
- global cookie_string
42
 
43
  url = f"https://www.tiket.com/ms-gateway/tix-flight-search/v3/search?origin={origin}&originType=AIRPORT&destination={destination}&destinationType=AIRPORT&adult={adult}&child={child}&infant={infant}&cabinClass={cabinClass}&departureDate={departureDate}&flexiFare=true&resultType={resultType}&searchType={searchType}&returnDate={returnDate}&enableVI=true"
44
  scraper = cloudscraper.create_scraper()
45
-
46
- clean_cookie = cookie_string.replace("\n", "").strip()
47
-
48
- cookie_dict = {}
49
-
50
- for item in clean_cookie.split("; "):
51
- if "=" in item:
52
- key, value = item.split("=", 1)
53
- print(key)
54
- if key == "session_refresh_token":
55
- continue
56
- cookie_dict[key] = value.encode('cp1252').decode('utf-8')
57
  headers = {
58
  "Accept": "*/*",
59
  "Content-Type": "application/json",
 
18
  session_refresh_token=eyJraWQiOiJpMXVPV2drM1Q1dlBmb1BDczJCODVBSm1obW40Nk5ETCJ9.eyJhdWQiOiJ0aWtldC5jb20vcnQiLCJzdWIiOiI2NzYxMjM5NzkzZGNjODJhNWZmNDE1YTMiLCJuYmYiOjE3MzQ0MTkzNTEsImlzcyI6Imh0dHBzOi8vd3d3…ZHkxNFdfjWxz3veFZHYRN8GhkWFe5UJte_yvcewVVvR7e5qVs5J_JbVzIZaDv1Rb39SEVHcb3ZUKoq5eOTaSKpCm7YA;
19
  cf_clearance=txA3F6mlyQt1XzsIY6OxCM86BmMswcmyX8XmPpOULc0-1734421561-1.2.1.1-Dqk4hE0_.4Y5OQkD6LPXGgC3Z0dfzvirBDr.209VtndL06wBVt.xUN1EGdQ7LBL50dIR_rE1y58KndTzS832O5lp4Iz9KoR8BIBVWX7tbDLfgaF1sABo4rsb_l_mmThS56EODLjin3QLZAC8RMZ10DFAGI6xgqsBv75uQjx.7Tduj3LbjPfjq14T4V6N6uwKn9Hn05t79vC.z_buGQYSZK2qTKcn3tA.pCQqOMG7RjVcffVbIPFWNOMfuYNrK5GC3mh.uERzdAw2FoOY4ddSDR4biGYxxwMDxI0A5v.DBdp4jgUL_BY5YSWwSfaS89ymKXj9gyplQ.FiRG6LmLRT_g"""
20
 
21
+ clean_cookie = cookie_string.replace("\n", "").strip()
22
+
23
+ cookie_dict = {}
24
+
25
+ for item in clean_cookie.split("; "):
26
+ if "=" in item:
27
+ key, value = item.split("=", 1)
28
+ if key == "session_refresh_token":
29
+ continue
30
+ cookie_dict[key] = value.encode('cp1252').decode('utf-8')
31
+
32
+
33
  @app.get("/")
34
  def greet_json():
35
  return {"Hello": "World!"}
 
50
  returnDate: str = "2024-12-21",
51
  # enableVI=true
52
  ):
53
+ global cookie_dict
54
 
55
  url = f"https://www.tiket.com/ms-gateway/tix-flight-search/v3/search?origin={origin}&originType=AIRPORT&destination={destination}&destinationType=AIRPORT&adult={adult}&child={child}&infant={infant}&cabinClass={cabinClass}&departureDate={departureDate}&flexiFare=true&resultType={resultType}&searchType={searchType}&returnDate={returnDate}&enableVI=true"
56
  scraper = cloudscraper.create_scraper()
 
 
 
 
 
 
 
 
 
 
 
 
57
  headers = {
58
  "Accept": "*/*",
59
  "Content-Type": "application/json",