celebi-pkg / flight-analysis

Python package to scrape flight data from Google Flights and analyzes prices. Can determine optimal flight from date, place, and price
https://kcelebi.github.io/flight-analysis/
MIT License
127 stars 38 forks source link

Support for Multiple Currencies and Currency Symbols #18

Open douiebyossef opened 1 year ago

douiebyossef commented 1 year ago

I hope you're doing well. I've created a pull request that adds support for multiple currencies and their corresponding currency symbols. This enhancement resolves the issue of returning None when accessing a price currency which is not $.

Here's a summary of the changes:

Added a list, CURRENCY_SYMBOLS_LIST, to the flight.py file, which contains various currency symbols. Added price_currency property from the Flight class. Updated the _classify_arg method in the Flight class to extract the currency symbol directly from the argument. Modified the data frame creation in the Flight.get_dataframe method of the scrape.py file to use a dynamic price column name, "Price (CURRENCY_SYMBOL)". These changes make the library more robust and user-friendly, as it now supports different currencies and provides accurate currency symbols.

Please review the pull request at your convenience. I'm open to any feedback or suggestions for improvement.

Thank you for your time and consideration.

kcelebi commented 1 year ago

Hello, thank you for taking the time to make this pull request, I really appreciate it. The issue of dealing with different currencies is one that I've been trying to tackle for some time, especially because it's not particularly easy to observe.

You're definitely on the right track with including a list of currency symbols and checking the args for them, however, the ones listed in your commit are not completely accurate to what Google Flights shows in its query. For example, Google Flights does not show a Turkish Lira as but rather TRY, a Kazakh Tenge isn't show as but rather KZT, and Ether Ξ just isn't supported.

There don't appear to be any query parameters that satisfy currency or location. The only way that I've discovered to easily change these things is either a VPN (not feasible for the package) or a button that loads at the bottom of the page conveniently labeled Currency which yields a menu of all the represented notes.

For the moment, I've earmarked this problem to be solved by creating a Selenium procedure to click this Currency button and either always select USD or select a currency that the user requests. The latter takes much more time to develop as each of the provided currencies need to be tested thoroughly for the clicking and scraping aspect. The former is easier, but still takes some time to develop and test.

This problem is important, however, not top priority on my list of to-do's as I've chosen to prioritize making the scraping procedure more robust to simple queries, cleaning up the caching procedures, and updating documentation to the most recent updates in v1.2.0. I will get to this at some point, however, if you'd rather not wait you're welcome to take a crack at it and update this PR.