Possibility of using local Playwright#43
Merged
AWeirdDev merged 3 commits intoAWeirdDev:mainfrom Mar 5, 2025
Merged
Conversation
jimmyliu03
pushed a commit
to jimmyliu03/google-flights
that referenced
this pull request
Dec 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am getting a 401 error when using the fallback method lately, most possibly because I made too many requests to the serverless Playwright!
So, I implemented a way of using good old local Playwright optionally.
The most important changes include updates to the documentation, core functions, and the addition of a new module to handle local Playwright fetching, as well as the inclusion of Playwright as an optional dependency.
Documentation Update:
docs/local.md: Added instructions for running Playwright locally, including installation steps and usage examples.Core Function Updates:
fast_flights/core.py: Added "local" as a valid mode forget_flightsandget_flights_from_filterfunctions, and implemented the logic to handle the "local" mode by calling a new function from thelocal_playwrightmodule. [1] [2] [3]New Module:
fast_flights/local_playwright.py: Created a new module to fetch flight data using Playwright locally, including an asynchronous function to interact with the browser and a synchronous function to fetch data based on provided parameters. It also sidesteps the cookie modal with the most amazing method of clicking on 'Accept all'.Dependencies:
pyproject.toml: Added an optional dependency for Playwright, allowing users to install it when they need to run Playwright locally. This should play nicely withpip, and attempting to install it locally with the[local]thing at the end worked, but I have no idea if it will work when the package is on PyPI (although, again, it should).Thank you for this amazing project, it is really useful :)