>>> print(fr().get_flight_details("DL200"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\api.py", line 97, in get_flight_details
return request.get_content()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\request.py", line 42, in get_content
return json.loads(content)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
>>> print(get_flight_details("DL200"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'get_flight_details' is not defined
>>> print(fr.get_flight_details("DL200"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: FlightRadar24API.get_flight_details() missing 1 required positional argument: 'flight_id'
>>> print(fr.get_flight_details("DL200","DL200"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\api.py", line 97, in get_flight_details
return request.get_content()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\request.py", line 42, in get_content
return json.loads(content)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
>>> stor=fr.get_flight_details("DL200","DL200")))
File "<stdin>", line 1
stor=fr.get_flight_details("DL200","DL200")))
^
SyntaxError: unmatched ')'
>>> stor=fr.get_flight_details("DL200","DL200"))
File "<stdin>", line 1
stor=fr.get_flight_details("DL200","DL200"))
^
SyntaxError: unmatched ')'
>>> stor=fr.get_flight_details("DL200","DL200")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\api.py", line 97, in get_flight_details
return request.get_content()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\request.py", line 42, in get_content
return json.loads(content)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
>>> stor=str(fr.get_flight_details("DL200","DL200"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\api.py", line 97, in get_flight_details
return request.get_content()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ivoie\AppData\Roaming\Python\Python311\site-packages\FlightRadar24\request.py", line 42, in get_content
return json.loads(content)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
>>>
for airport in airports:
nyoomzones=nyoomzones+1
a=ast.literal_eval(str(airport))
a=str(a)
#a=a.replace("' ",'" ')
a=a.replace(": '",': "')
a=a.replace("{'",'{"')
a=a.replace("'}",'"}')
a=a.replace("':",'":')
a=a.replace("',",'",')
a=a.replace(", '",', "')
a=a.replace(": '",': "')
a=a.replace("\\xa0","")
# print(a)
b=json.loads(a)
# print(f'\n airport #{nyoomzones} of {len(airports)} {b["name"]} , {b["country"]} , (iata code: {b["iata"]} , icao code: {b["icao"]} ) \n location : " longditude : {b["lon"]} latitude : {b["lat"]} altitude : {b["alt"]} " \n ')
nyoomspot.append(b["name"]) #Airport name
nyoomno.append(nyoomzones) #airport number
nyoomcontroler.append(b["country"]) #Airport country
nyoomiata.append(b["iata"]) #Airport IATA code
nyoomicao.append(b["icao"]) #Airport ICAO code
nyoomlat.append(b["lat"]) #Airport latitude x (left , right)
nyoomlon.append(b["lon"]) #Airport londitude y (forward , back)
nyoomalt.append(b["alt"]) #Airport Altitude z (up down)
nyoominfo = fr_api.get_airport(nyoomicao[f])
c=ast.literal_eval(str(nyoominfo))
c=str(c)
#a=a.replace("' ",'" ')
c=c.replace(": '",': "')
c=c.replace("{'",'{"')
c=c.replace("'}",'"}')
c=c.replace("':",'":')
c=c.replace("',",'",')
c=c.replace(", '",', "')
c=c.replace(": '",': "')
c=c.replace("\\xa0","")
c=c.replace("['", '["')
c=c.replace("']", '"]')
c=c.replace("None", '"None"')
c=c.replace("True", 'true')
c=c.replace("False", 'false')
c=c.replace("http://", '')
c=c.replace("https://", '')
print(c)
d=json.loads(c)
#{} {} {} {} {} {} {}
infoName=d['name']
infoCode=d['code']
infoPosition=d['position']
infoTimezone=d['timezone']
infoVisible=d['visible']
infoWebsite=d['website']
infoStats=d['stats']
print(f"name : {infoName} \n\n code : {infoCode} \n\n pos : {infoPosition} \n\n timezone : {infoTimezone} \n\n visib : {infoVisible} \n\n webs : {infoWebsite} \n\n stats : {infoStats} ")
print(f" Details about Airport #{nyoomno[f]}\n=======================================\nName : {nyoomspot[f]} Longditude : {nyoomlon[f]}\nCountry : {nyoomcontroler[f]} Latitude : {nyoomlat[f]}\nA.L.No : {nyoomno[f]} Altitude : {nyoomalt[f]}\nIATA : {nyoomiata[f]} ICAO : {nyoomicao[f]}")
# print(f"Airport information : {nyoominfo} ")
# print(f"METAR REPORT FROM {nyoomspot} ({nyoomicao[f]}): {gd.Metar(nyoomicao[f]).getAttribute('metar')}\nMORE INFO: https://meteocentre.com/doc/metar.html \n DOI : {gd.Metar(nyoomicao[f]).getAttribute('data_date')} \n Changements : {gd.Metar(nyoomicao[f]).getAttribute('changements')} \n auto : {gd.Metar(nyoomicao[f]).getAttribute('auto')} \n Wind : {gd.Metar(nyoomicao[f]).getAttribute('wind')} \n RVR : {gd.Metar(nyoomicao[f]).getAttribute('rvr')} \n Weather : {gd.Metar(nyoomicao[f]).getAttribute('weather')} \n Cloud : {gd.Metar(nyoomicao[f]).getAttribute('cloud')} \n tempretures : {gd.Metar(nyoomicao[f]).getAttribute('temperatures')} \n qnh : {gd.Metar(nyoomicao[f]).getAttribute('qnh')} \n visibility : {gd.Metar(nyoomicao[f]).getAttribute('visibility')} \n propertys : {gd.Metar(nyoomicao[f]).getAttribute('properties')} \n VMC : {gd.Metar(nyoomicao[f]).getAttribute('vmc')} \n")
print(f"Generating full report '{nyoomspot[f]} on {stmp}.txt'")
if (os.path.exists(f"C:/Users/{os.getlogin()}/AIRPORTREPORTS/")==False):
os.mkdir(f"C:/Users/{os.getlogin()}/AIRPORTREPORTS/")
with open(f"C:/Users/{os.getlogin()}/AIRPORTREPORTS/{nyoomspot[f]} on {stmp}.txt","w",encoding="utf-8") as frr:
frr.write(f"Details about Airport #{nyoomno[f]} + METAR REPORT \n=======================================\nName : {nyoomspot[f]} Longditude : {nyoomlon[f]}\nCountry : {nyoomcontroler[f]} Latitude : {nyoomlat[f]}\nA.L.No : {nyoomno[f]} Altitude : {nyoomalt[f]}\nIATA : {nyoomiata[f]} ICAO : {nyoomicao[f]}")
frr.write(f"\nAirport information : {c}")
However I am stonewalled when manually attempting to fetch info on a certain flight
For example
DL200 which is a flight from Atlanta USA to Gautueng SOUTH AFRICA
The so called JSON pharser cannot read the data because it doesnt comply with RFC 8259 , one such issue in the garbaled mess of data is the lack of doubble quotes , and the capitalisation of the first letter of booleans where they should be lowercase. Some values such as None get returned without being quoted with the doubbles , thus throws a missing value error