AWeirdDev / flights

Fast, robust Google Flights scraper (API) for Python. (Probably)
https://pypi.org/project/fast-flights
35 stars 9 forks source link

Any request returns - RuntimeError: No flights found. (preflight checked) #4

Closed AlexanderOllman closed 2 months ago

AlexanderOllman commented 4 months ago

Steps Performed:

  1. New, clean conda environment
  2. pip3 install fast-flights
  3. Copied example code
  4. Ran example code

Output:

/Users/ollman/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
Traceback (most recent call last):
  File "/Users/ollman/flight-track/app.py", line 26, in <module>
    result =get_flights(filter)
  File "/Users/ollman/Library/Python/3.9/lib/python/site-packages/fast_flights/core.py", line 125, in get_flights
    return get_flights(
  File "/Users/ollman/Library/Python/3.9/lib/python/site-packages/fast_flights/core.py", line 133, in get_flights
    raise RuntimeError(
RuntimeError: No flights found. (preflight checked)
Possible reasons:
- Invalid query (e.g., date is in the past or cannot be booked)
- Invalid airport

Attempted Fixes:

AWeirdDev commented 4 months ago

Hi there,

The example code given is 2024-07-02, a long time ago. Have you changed the value or parameters? If not, could you provide your code?

Thanks, AWeirdDev

AlexanderOllman commented 4 months ago

I changed it to a newer date, and that is when it returned the error.

However, noting that some dates do work (e.g. 2024/08/02), but others such as 2024/11/02 do not, and result in the error.

E.g. this produces the error:

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
        FlightData(
            date="2024-11-02",  # Date of departure
            from_airport="TPE", 
            to_airport="MYJ"
        ),
        # ... include more for round trips
    ],
    trip="one-way",  # Trip (round-trip, one-way)
    seat="economy",  # Seat (economy, premium-economy, business or first)
    passengers=Passengers(
        adults=2,
        children=1,
        infants_in_seat=0,
        infants_on_lap=0
    ),
)

# Get flights with a filter
result = get_flights(filter)

# The price is currently... low/typical/high
print("The price is currently", result.current_price)

Entering these airports and this date manually for one way returns a valid result.

AlexanderOllman commented 4 months ago

Update: This configuration was not working prior to my original post, and is working now. I am unsure as to why.

However, what this code returns is a price=0.0. All results return price=0.0.

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
        FlightData(
            date="2024-12-13",  # Date of departure
            from_airport="LAX", 
            to_airport="SYD"
        ),
        FlightData(
            date="2025-01-04",  # Date of departure
            from_airport="SYD", 
            to_airport="LAX"
        ),
        # ... include more for round trips
    ],
    trip="round-trip",  # Trip (round-trip, one-way)
    seat="economy",  # Seat (economy, premium-economy, business or first)
    passengers=Passengers(
        adults=1,
        children=0,
        infants_in_seat=0,
        infants_on_lap=0
    ),
)

# Get flights with a filter
result = get_flights(filter)
flight = result.flights[0]

# The price is currently... low/typical/high
print("The price is currently", result.current_price)

print(flight)

Result:

Flight(is_best=True, name='Delta', departure='10:25 PM on Fri, Dec 13', arrival='8:35 AM on Sun, Dec 15', arrival_time_ahead='+2', duration='15 hr 10 min', stops=0, delay=None, price=0.0)
AWeirdDev commented 4 months ago

Hey,

Have you tried taking a look at the web version of the page? That may help a lot!

Thanks