Created
November 9, 2019 18:57
-
-
Save mmsesay/714b3bba941b7923df2ef1c76a3ae63b to your computer and use it in GitHub Desktop.
This is the code that i got so far for today
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import csv | |
import json | |
import time | |
import requests | |
currentTime = int(time.time()) #currentTime in second | |
takeOffTime = currentTime - 3600 * 48 # 48h in the past | |
# all departure flights | |
def departures(airport): | |
url = f'https://opensky-network.org/api/flights/departure?airport={airport}&begin=1517227200&end=1517230800' | |
response = requests.get(url) | |
res = response.json() # pass data as json | |
# print(res) # print the reterived data | |
dept = '' | |
arr = '' | |
# loop through the res | |
for r in res: | |
dept = r['estDepartureAirport'] | |
arr = r['estArrivalAirport'] | |
print('Aeparture AirPort: {} - Arrival Airport: {}'.format(dept,arr)) | |
print('--------------------------------------------------') | |
# read from the csv file | |
# with open('./airports.csv', mode='r') as csvfile: | |
# # reading the csv file | |
# content = csv.reader(csvfile) | |
# # loop through the csvfile | |
# for con in content: | |
# # check if the dept is in csv file | |
# if con[5] == dept: | |
# lat = con[6] | |
# lon = con[7] | |
# print('lat: {} | lon: {}'.format(lat,lon)) | |
# else: | |
# print('Not found') | |
departures("KBDR") | |
# KBDR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment