FergM / flight_tables

Flight Tables lets you save public Arrivals and Departures infomation to a standardised csv file.
MIT License
1 stars 1 forks source link

Request to data source is outdated. Results in KeyError: 'flightSummaryList'` #11

Open mitscay opened 4 years ago

mitscay commented 4 years ago

I have used the following on my script with Anaconda, since April but since 24/06/2020 whenever I try to run the library it returns the following:

`--------------------------------------------------------------------------- KeyError Traceback (most recent call last)

in 1 # Save Arrivals CSV ----> 2 FlightTables.arrivals_csv("2020-07-01") 3 4 # Save Departures CSV 5 FlightTables.departures_csv("2020-07-01") ~\Anaconda3\lib\site-packages\flight_tables\flight_tables.py in arrivals_csv(self, iso_date_str) 10 @classmethod 11 def arrivals_csv(self, iso_date_str): ---> 12 self.date_to_csv(iso_date_str, "arrivals") 13 14 @classmethod ~\Anaconda3\lib\site-packages\flight_tables\flight_tables.py in date_to_csv(iso_date_str, direction) 30 heathrow_raw_dict = fetch_heathrow_data(iso_date_str, direction) 31 ---> 32 batch_info = extract_batch_heathrow(heathrow_raw_dict) 33 34 parsed_flights = ParsedFlights(batch_info) ~\Anaconda3\lib\site-packages\flight_tables\heathrow_parsing.py in extract_batch_heathrow(response) 113 batch_info = [] # List with `flight_info` from multiple flights 114 --> 115 raw_flights = response['flightSummaryList']['flight'] 116 117 for flight in raw_flights: KeyError: 'flightSummaryList'` I am not sure how to resolve this though.
FergM commented 4 years ago

Hi, thanks for raising the issue.

tldr: The data source has changed. The get request now needs a header.

Quick Fix:

For context:

Let me know if you have any other feedback about the documentation or context about your use case.

All the best

mitscay commented 4 years ago

Hi there, thank you for your quick feedback. As I am only a moderate user I am not quite certain how to go ahead and modify your script from my notebook? I have tried running the different scripts flight_tables.py, heathrow_parsing.py etc and I substituted the line you mentioned, however I keep receiving the same error message.

FergM commented 4 years ago

I've saved a fix to the develop branch for a start.

It should work if you save the develop branch locally and do command line execution (see README.md).

I'm planning to pull to master and update PyPi. Once that's done pip upgrade will work.

mitscay commented 4 years ago

Thanks @FergM for your help.

FergM commented 3 years ago

December 2020 Update: