-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API degisikligi #3
Comments
sağlık olsun |
Güncelleme gelecek mi? |
Hocam bir güncelleme yapsanız veya bir yol gösterseniz üzerinde uğraşsak halledebilir miyiz :'( |
API güncellendiği için servis çalışmıyor sanırsam. Aşağıda örnek kod bloğunu paylaşıyorum. import datetime
import time
import requests
url = "https://web-api-prod-ytp.tcddtasimacilik.gov.tr/tms/train/train-availability?environment=dev&userId=1"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "tr",
"Authorization": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJlVFFicDhDMmpiakp1cnUzQVk2a0ZnV196U29MQXZIMmJ5bTJ2OUg5THhRIn0.eyJleHAiOjE3MjEzODQ0NzAsImlhdCI6MTcyMTM4NDQxMCwianRpIjoiYWFlNjVkNzgtNmRkZS00ZGY4LWEwZWYtYjRkNzZiYjZlODNjIiwiaXNzIjoiaHR0cDovL3l0cC1wcm9kLW1hc3RlcjEudGNkZHRhc2ltYWNpbGlrLmdvdi50cjo4MDgwL3JlYWxtcy9tYXN0ZXIiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMDAzNDI3MmMtNTc2Yi00OTBlLWJhOTgtNTFkMzc1NWNhYjA3IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoidG1zIiwic2Vzc2lvbl9zdGF0ZSI6IjAwYzM4NTJiLTg1YjEtNDMxNS04OGIwLWQ0MWMxMTcyYzA0MSIsImFjciI6IjEiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiZGVmYXVsdC1yb2xlcy1tYXN0ZXIiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJvcGVuaWQgZW1haWwgcHJvZmlsZSIsInNpZCI6IjAwYzM4NTJiLTg1YjEtNDMxNS04OGIwLWQ0MWMxMTcyYzA0MSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoid2ViIiwiZ2l2ZW5fbmFtZSI6IiIsImZhbWlseV9uYW1lIjoiIn0.AIW_4Qws2wfwxyVg8dgHRT9jB3qNavob2C4mEQIQGl3urzW2jALPx-e51ZwHUb-TXB-X2RPHakonxKnWG6tDIP5aKhiidzXDcr6pDDoYU5DnQhMg1kywyOaMXsjLFjuYN5PAyGUMh6YSOVsg1PzNh-5GrJF44pS47JnB9zk03Pr08napjsZPoRB-5N4GQ49cnx7ePC82Y7YIc-gTew2baqKQPz9_v381Gbm2V38PZDH9KldlcWut7kqQYJFMJ7dkM_entPJn9lFk7R5h5j_06OlQEpWRMQTn9SQ1AYxxmZxBu5XYMKDkn4rzIIVCkdTPJNCt5PvjENjClKFeUA1DOg",
"unit-id": "3895",
"Content-Type": "application/json",
"Sec-GPC": "1",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site"
}
data = {
"searchRoutes": [
{
"departureStationId": 98,
"departureStationName": "ANKARA GAR",
"arrivalStationId": 1323,
"arrivalStationName": "İSTANBUL(BOSTANCI)",
"departureDate": "12-12-2024 21:00:00"
}
],
"passengerTypeCounts": [
{
"id": 0,
"count": 1
}
],
"searchReservation": False
}
resp = requests.post(url, headers=headers, json=data)
resp = resp.json()
main_keys = resp.keys()
train_legs = resp[list(main_keys)[0]]
train_legs_keys = train_legs[0].keys()
train_legs_keys = list(train_legs_keys)
train_availabilities = train_legs[0][train_legs_keys[0]]
for index, train_availability in enumerate(train_availabilities):
train_info = list(train_availability.keys())
available_seat_info = train_availability[train_info[0]][0]["cabinClassAvailabilities"]
for available_seat in available_seat_info:
if available_seat["cabinClass"]["name"] == "EKONOMİ":
departure_time = train_availability[train_info[0]][0]["trainSegments"][0]["departureTime"]
departure_time = datetime.datetime.fromisoformat(departure_time)
# sunucular ingilterede heralde
departure_time = departure_time + datetime.timedelta(hours=3)
print(departure_time, end="\t")
print(available_seat["availabilityCount"])
# 2024-12-13 07:30:00
if departure_time == datetime.datetime(2024, 12, 13, 9, 50):
print("ahan da buldum") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TCDD guncelleme yapti ve sorgu sonuclari degisti.
The text was updated successfully, but these errors were encountered: