Sushill

Untitled

Mar 26th, 2025
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.66 KB | None | 0 0
  1. async def generate_code(x, y):
  2.     x += 1.1
  3.     y += 2.3
  4.  
  5.     timestamp = str(int(time.time() * 1000))
  6.  
  7.     x_integer = str(x).split(".")[0]
  8.     x_last_digit = x_integer[-1]
  9.  
  10.     x_first_decimal = str(x).split(".")[1][0] if len(str(x).split(".")) > 1 else "0"
  11.  
  12.     y_integer = str(y).split(".")[0]
  13.     y_last_digit = y_integer[-1]
  14.  
  15.     y_first_decimal = str(y).split(".")[1][0] if len(str(y).split(".")) > 1 else "0"
  16.  
  17.     result_string = x_last_digit + timestamp[-1] + y_last_digit + timestamp[-2] + x_first_decimal + timestamp[-3] + y_first_decimal
  18.  
  19.     encoded = base64.b64encode(result_string.encode()).decode()
  20.  
  21.     return encoded
  22.  
  23.  
  24. async def fetch_physicians_data(lat, lon, req_value):
  25.  
  26.  
  27.     url = "https://arztsuche.116117.de/api/data"
  28.     headers = {
  29.     "Cache-Control": "no-cache, no-store, max-age=0, must-revalidate",
  30.     "Connection": "keep-alive",
  31.     "Content-Type": "application/json",
  32.     "Accept": "application/json, text/plain, */*",
  33.     "Accept-Encoding": "gzip, deflate, br, zstd",
  34.     "Accept-Language": "en-US,en;q=0.5",
  35.     "Authorization": "Basic YmRwczpma3I0OTNtdmdfZg==",
  36.     "Cookie": "TS013407f0=0111b4ea971c14c0852f62849de60ae01614d47c1f13b104220dc02c8631752eba5f5753d132c30f3dcb7448ad73e959f70bcb6b6e3c754a693b3967489be8577193d248dd; cookieConsent=level1; JSESSIONID=D22DE6C614093EC68869A9B07060FABE",
  37.     "Host": "arztsuche.116117.de",
  38.     "Origin": "https://arztsuche.116117.de",
  39.     "Referer": "https://arztsuche.116117.de/",
  40.     "Sec-Fetch-Dest": "empty",
  41.     "Sec-Fetch-Mode": "cors",
  42.     "Sec-Fetch-Site": "same-origin",
  43.     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0",
  44.     "req-val": req_value,
  45.     "Priority": "u=0"
  46. }
  47.  
  48.     payload = {
  49.         "r": 900,
  50.         "lat": lat,
  51.         "lon": lon,
  52.         "filterSelections": [
  53.             {
  54.                 "title": "Fachgebiet Kategorie",
  55.                 "fieldName": "fgg",
  56.                 "selectedCodes": ["03"]
  57.             }
  58.         ],
  59.         "locOrigin": req_value,
  60.         "initialSearch": True,
  61.         "viaDeeplink": False
  62.     }
  63.  
  64.     response = requests.post(url, json=payload, headers = headers, impersonate='chrome')
  65.  
  66.     return response.json()
  67.  
  68. async def main():
  69.     lat = 48.37204385
  70.     lon = 10.89391765
  71.     req_value = await generate_code(lon, lat)
  72.  
  73.     return await fetch_physicians_data(lat, lon, req_value)
  74.  
  75. if __name__ == '__main__':
  76.     start_time = time.time()
  77.     results = asyncio.run(main())
  78.     print(results)
  79.     end_time = time.time()
  80.     execution_time = round(end_time - start_time, 2)
  81.     print(f"Took {execution_time} seconds | {round(execution_time / 60, 2)} minutes.")
  82.  
Add Comment
Please, Sign In to add comment