Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having an issue with searching for Sydney flights (SYD) #24

Open
chansters opened this issue Jan 8, 2025 · 4 comments
Open

Having an issue with searching for Sydney flights (SYD) #24

chansters opened this issue Jan 8, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@chansters
Copy link

Thanks for this great work! It's working really well. However, I'm running into an issue when I try to search for Sydney (SYD) flights:

File "/opt/miniconda3/lib/python3.12/site-packages/fast_flights/core.py", line 47, in get_flights_from_filter
return parse_response(res)
^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/fast_flights/core.py", line 151, in parse_response
raise RuntimeError("No flights found:\n{}".format(r.text_markdown))

I'm trying to search for SYD to SFO flights. It works on the Google Flights website but keeps throwing this error. Any ideas?

Copy link

dosubot bot commented Jan 8, 2025

Hey @chansters! 👋 I'm here to help you with any bugs, questions, or contributions. I'll do my best to assist you while you wait for a human maintainer.

The "No flights found" RuntimeError occurs when the flights list is empty after attempting to parse the response from the Google Flights page. This suggests that the HTML structure expected by the parser does not match the actual structure of the response, leading to no flights being extracted.

To resolve this issue, consider the following steps:

  1. Verify Parameters: Ensure that the parameters being sent to the fetch function are correct and match the expected format for the Google Flights page. The tfs parameter, in particular, should be correctly encoded.

  2. Update CSS Selectors: Check if there have been any changes in the HTML structure of the Google Flights page that require updating the CSS selectors in the parse_response function. The selectors used are div[jsname="IWWDBc"], div[jsname="YdtKid"], and they need to match the current structure of the page to extract flight data successfully.

These steps should help in addressing the issue you're encountering [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the bug Something isn't working label Jan 8, 2025
@AWeirdDev
Copy link
Owner

AWeirdDev commented Jan 8, 2025

Have you tried the fallback? Here's the docs.

@chansters
Copy link
Author

chansters commented Jan 8, 2025

Have you tried the fallback? Here's the docs.

I'm currently calling your API like this, which I believe is using the fallback method? I've blanked out the dates for privacy reasons as I'm doing this for personal trip planning. The first three routes work just fine but it's failing on the fourth. I've tried just querying using the last route alone (without the first three) and it still fails.

flight_queries = [
    FlightData(date="xx", from_airport="SFO", to_airport="LHR", max_stops=0), 
    FlightData(date="xx", from_airport="ZRH", to_airport="TPE", max_stops=1),  
    FlightData(date="xx, from_airport="TPE", to_airport="SYD", max_stops=1), 
    FlightData(date="xx", from_airport="SYD", to_airport="SFO", max_stops=1),     
]

route_results = []

for query in flight_queries:
    result: Result = get_flights(
        flight_data=[query],
        trip="one-way",
        seat="economy",
        passengers=Passengers(adults=2, children=2, infants_in_seat=0, infants_on_lap=0),
        fetch_mode="fallback",
    )

Just read your docs link, I will try the force method: force-fallback – Forces using the fallback.

@AWeirdDev
Copy link
Owner

Did the force-fallback mode work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants