Open JobeOneKenobi opened 1 month ago
Hey there,
Could you please clarify what "Cookies reference is not working" mean? As for the broken parse_response()
function, could you please provide an error log pointing where the error occurred or what type of error was it?
P.S. I was in a rush so I wasn't aware of my code being that broken, thanks for pointing this out. I'll look into the code tomorrow (if possible). Thanks!
Best
Yes, I'll confess I'm a novice with Github, and by no means any expert coder.
For the cookies thing actually it looks like I just needed to add an import line:
Ope, tack that back, when I do that it gives this error:
C:\Users\jobel\PycharmProjects\pythonProject\venv\Scripts\python.exe "C:\Users\jobel\PycharmProjects\pythonProject\Flight Helper\main.py"
Traceback (most recent call last):
File "C:\Users\jobel\PycharmProjects\pythonProject\Flight Helper\main.py", line 2, in
Process finished with exit code 1
But anyways this is the error code for running it without the cookies line, that is the issue with parsing the response which seems to be the bigger problem (I haven't encountered any need for the cookies thing yet anyway):
Traceback (most recent call last):
File "C:\Users\jobel\PycharmProjects\pythonProject\Flight Helper\main.py", line 28, in
IndexError: list index out of range
Process finished with exit code 1
###
Now you mentioned a log file? I'm assuming you mean adding code that saves out errors like this to a log / txt file so that I don't have to copy past efrom the output screen? That is a good idea I should do that.
Hi there,
I've updated fast-flights
to v1.2
.
Cookies
couldn't be imported because of the missing import in __init__.py
. As for the IndexError
, I assume it's because the departure time is not present sometimes.
pip install -U fast-flights
Let me know if I made other silly mistakes!
Best, AWeirdDev
Alright new, and even wierder, parse response error. Old ones seem to to be resolved using same modified example code, updated to 1.2 and got the following error:
Traceback (most recent call last):
File "C:\Users\jobel\SynologyDrive\PycharmProjects\pythonProject\flights_package_test.py", line 28, in
Process finished with exit code 1
But here's what's wierd I went in and added some print statements to the nonstop parse / code and got this for this same code / result:
1 stop ['1', 'stop'] 1 stop ['1', 'stop'] 1 stop ['1', 'stop'] 2 stops ['2', 'stops'] 2 stops ['2', 'stops'] 1 stop ['1', 'stop'] 2 stops
So I have no clue how it's parsing / splitting out an empty string? '' Freaking wierd.
Here is my code just to be sure:
from fast_flights import FlightData, Passengers, create_filter, get_flights, Cookies
filter1 = create_filter( flight_data=[
FlightData(
date="2024-08-21", # Date of departure
from_airport="IAD",
to_airport="JFK"
),
# ... include more for round trips and multi-city trips
],
trip="one-way", # Trip (round-trip, one-way, multi-city)
seat="economy", # Seat (economy, premium-economy, business or first)
passengers=Passengers(
adults=1,
children=0,
infants_in_seat=0,
infants_on_lap=0
),
)
result = get_flights( filter1, dangerously_allow_looping_last_item=True, cookies=Cookies.new().to_dict(), currency="USD", language="en" )
print("The price is currently", result.current_price)
print(result.flights[1])
Tried a few different dates and airports
V1 works the same using the v0 functionality, but when I try the new formatting for the get_flights, two issues:
I'm testing it in an isolated environment with a simple main script, and installed it with pip only here is my test code
from fast_flights import FlightData, Passengers, create_filter, get_flights
Create a new filter
filter = create_filter( flight_data=[
Include more if it's not a one-way trip
)
Get flights with a filter
result = get_flights( filter, dangerously_allow_looping_last_item=True, cookies=Cookies.new().to_dict(), currency="USD", language="en" )
The price is currently... low/typical/high
print("The price is currently", result.current_price)
Display the first flight
print(result.flights[0])