From e7b7d82b206d7d05c3f052e8ae1fed6a6c82d545 Mon Sep 17 00:00:00 2001 From: Emanuele Salonico Date: Thu, 3 Aug 2023 17:54:52 +0200 Subject: [PATCH] refactor: change package name to flight_analysis --- README.md | 2 +- flight_analysis.ipynb | 283 +++++++----------- flight_analysis.py | 4 +- .../__init__.py | 0 .../database.py | 0 .../flight.py | 0 .../scrape.py | 0 7 files changed, 118 insertions(+), 171 deletions(-) rename src/{google_flight_analysis => flight_analysis}/__init__.py (100%) rename src/{google_flight_analysis => flight_analysis}/database.py (100%) rename src/{google_flight_analysis => flight_analysis}/flight.py (100%) rename src/{google_flight_analysis => flight_analysis}/scrape.py (100%) diff --git a/README.md b/README.md index a765cdf..48ffe9e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The whole project is written has been created with Python 3.11 and is based on t A very simple example of the main scraping functionality could be the following (get all flight from Munich (MUC) to Los Angeles (LAX) on May 28th, 2023): ``` -from google_flight_analysis.scrape import * +from flight_analysis.scrape import * flights = Scrape("MUC", "LAX", "2023-05-28") flights.data diff --git a/flight_analysis.ipynb b/flight_analysis.ipynb index 1dd64c9..4ed10ce 100644 --- a/flight_analysis.ipynb +++ b/flight_analysis.ipynb @@ -2,56 +2,26 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [ - { - "ename": "", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31mRunning cells with '/Users/emanuelesalonico/opt/anaconda3/envs/accenture/bin/python' requires the ipykernel package.\n", - "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n", - "\u001b[1;31mCommand: 'conda install -p /Users/emanuelesalonico/opt/anaconda3/envs/accenture ipykernel --update-deps --force-reinstall'" - ] - } - ], + "outputs": [], "source": [ - "from src.google_flight_analysis.scrape import Scrape" + "from src.flight_analysis.scrape import Scrape" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": {}, - "outputs": [ - { - "ename": "WebDriverException", - "evalue": "Message: disconnected: not connected to DevTools\n (failed to check if window was closed: disconnected: not connected to DevTools)\n (Session info: headless chrome=114.0.5735.198)\nStacktrace:\n0 chromedriver 0x0000000105333f48 chromedriver + 4226888\n1 chromedriver 0x000000010532c4f4 chromedriver + 4195572\n2 chromedriver 0x0000000104f70d68 chromedriver + 281960\n3 chromedriver 0x0000000104f59db4 chromedriver + 187828\n4 chromedriver 0x0000000104f7ad54 chromedriver + 322900\n5 chromedriver 0x0000000104fe2e30 chromedriver + 749104\n6 chromedriver 0x0000000104f9ff1c chromedriver + 474908\n7 chromedriver 0x0000000104fa0ef4 chromedriver + 478964\n8 chromedriver 0x00000001052f559c chromedriver + 3970460\n9 chromedriver 0x00000001052f96f0 chromedriver + 3987184\n10 chromedriver 0x00000001052ff5b4 chromedriver + 4011444\n11 chromedriver 0x00000001052fa2fc chromedriver + 3990268\n12 chromedriver 0x00000001052d21c0 chromedriver + 3826112\n13 chromedriver 0x0000000105316088 chromedriver + 4104328\n14 chromedriver 0x00000001053161e0 chromedriver + 4104672\n15 chromedriver 0x0000000105325f28 chromedriver + 4169512\n16 libsystem_pthread.dylib 0x00000001a788bfa8 _pthread_start + 148\n17 libsystem_pthread.dylib 0x00000001a7886da0 thread_start + 8\n", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mWebDriverException\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[6], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m flights \u001b[39m=\u001b[39m Scrape(\u001b[39m\"\u001b[39m\u001b[39mMUC\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39mLAX\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39m2023-10-28\u001b[39m\u001b[39m\"\u001b[39m, export\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m)\n\u001b[0;32m----> 2\u001b[0m flights\u001b[39m.\u001b[39;49mrun_scrape()\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/src/google_flight_analysis/scrape.py:39\u001b[0m, in \u001b[0;36mScrape.run_scrape\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mrun_scrape\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[0;32m---> 39\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_data \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_scrape_data()\n\u001b[1;32m 41\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_export:\n\u001b[1;32m 42\u001b[0m Flight\u001b[39m.\u001b[39mexport_to_csv(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_data, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_origin,\n\u001b[1;32m 43\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_dest, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_date_leave, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_date_return)\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/src/google_flight_analysis/scrape.py:143\u001b[0m, in \u001b[0;36mScrape._scrape_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 141\u001b[0m driver \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcreate_driver()\n\u001b[1;32m 142\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_url \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_make_url()\n\u001b[0;32m--> 143\u001b[0m flight_results \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_get_results(driver)\n\u001b[1;32m 144\u001b[0m driver\u001b[39m.\u001b[39mquit()\n\u001b[1;32m 146\u001b[0m \u001b[39mreturn\u001b[39;00m flight_results\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/src/google_flight_analysis/scrape.py:172\u001b[0m, in \u001b[0;36mScrape._get_results\u001b[0;34m(self, driver)\u001b[0m\n\u001b[1;32m 170\u001b[0m results \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 171\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 172\u001b[0m results \u001b[39m=\u001b[39m Scrape\u001b[39m.\u001b[39;49m_make_url_request(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_url, driver)\n\u001b[1;32m 173\u001b[0m \u001b[39mexcept\u001b[39;00m TimeoutException:\n\u001b[1;32m 174\u001b[0m logger\u001b[39m.\u001b[39merror(\n\u001b[1;32m 175\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mScrape timeout reached. It could mean that no flights exist for the combination of airports and dates.\u001b[39m\u001b[39m\"\u001b[39m)\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/src/google_flight_analysis/scrape.py:284\u001b[0m, in \u001b[0;36mScrape._make_url_request\u001b[0;34m(url, driver)\u001b[0m\n\u001b[1;32m 281\u001b[0m driver\u001b[39m.\u001b[39mget(url)\n\u001b[1;32m 283\u001b[0m \u001b[39m# detect Google's Terms & Conditions page (not always there, only in EU)\u001b[39;00m\n\u001b[0;32m--> 284\u001b[0m \u001b[39mif\u001b[39;00m Scrape\u001b[39m.\u001b[39m_identify_google_terms_page(driver\u001b[39m.\u001b[39;49mpage_source):\n\u001b[1;32m 285\u001b[0m WebDriverWait(driver, timeout)\u001b[39m.\u001b[39muntil(\n\u001b[1;32m 286\u001b[0m \u001b[39mlambda\u001b[39;00m s: Scrape\u001b[39m.\u001b[39m_identify_google_terms_page(s\u001b[39m.\u001b[39mpage_source))\n\u001b[1;32m 288\u001b[0m \u001b[39m# click on accept terms button\u001b[39;00m\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/.venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:541\u001b[0m, in \u001b[0;36mWebDriver.page_source\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 532\u001b[0m \u001b[39m@property\u001b[39m\n\u001b[1;32m 533\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mpage_source\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mstr\u001b[39m:\n\u001b[1;32m 534\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Gets the source of the current page.\u001b[39;00m\n\u001b[1;32m 535\u001b[0m \n\u001b[1;32m 536\u001b[0m \u001b[39m :Usage:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 539\u001b[0m \u001b[39m driver.page_source\u001b[39;00m\n\u001b[1;32m 540\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 541\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mexecute(Command\u001b[39m.\u001b[39;49mGET_PAGE_SOURCE)[\u001b[39m\"\u001b[39m\u001b[39mvalue\u001b[39m\u001b[39m\"\u001b[39m]\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/.venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:440\u001b[0m, in \u001b[0;36mWebDriver.execute\u001b[0;34m(self, driver_command, params)\u001b[0m\n\u001b[1;32m 438\u001b[0m response \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcommand_executor\u001b[39m.\u001b[39mexecute(driver_command, params)\n\u001b[1;32m 439\u001b[0m \u001b[39mif\u001b[39;00m response:\n\u001b[0;32m--> 440\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49merror_handler\u001b[39m.\u001b[39;49mcheck_response(response)\n\u001b[1;32m 441\u001b[0m response[\u001b[39m\"\u001b[39m\u001b[39mvalue\u001b[39m\u001b[39m\"\u001b[39m] \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_unwrap_value(response\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mvalue\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m))\n\u001b[1;32m 442\u001b[0m \u001b[39mreturn\u001b[39;00m response\n", - "File \u001b[0;32m~/Library/CloudStorage/GoogleDrive-esalonico@gmail.com/My Drive/SYNC/Dev/Flights/flight-analysis/.venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py:245\u001b[0m, in \u001b[0;36mErrorHandler.check_response\u001b[0;34m(self, response)\u001b[0m\n\u001b[1;32m 243\u001b[0m alert_text \u001b[39m=\u001b[39m value[\u001b[39m\"\u001b[39m\u001b[39malert\u001b[39m\u001b[39m\"\u001b[39m]\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mtext\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 244\u001b[0m \u001b[39mraise\u001b[39;00m exception_class(message, screen, stacktrace, alert_text) \u001b[39m# type: ignore[call-arg] # mypy is not smart enough here\u001b[39;00m\n\u001b[0;32m--> 245\u001b[0m \u001b[39mraise\u001b[39;00m exception_class(message, screen, stacktrace)\n", - "\u001b[0;31mWebDriverException\u001b[0m: Message: disconnected: not connected to DevTools\n (failed to check if window was closed: disconnected: not connected to DevTools)\n (Session info: headless chrome=114.0.5735.198)\nStacktrace:\n0 chromedriver 0x0000000105333f48 chromedriver + 4226888\n1 chromedriver 0x000000010532c4f4 chromedriver + 4195572\n2 chromedriver 0x0000000104f70d68 chromedriver + 281960\n3 chromedriver 0x0000000104f59db4 chromedriver + 187828\n4 chromedriver 0x0000000104f7ad54 chromedriver + 322900\n5 chromedriver 0x0000000104fe2e30 chromedriver + 749104\n6 chromedriver 0x0000000104f9ff1c chromedriver + 474908\n7 chromedriver 0x0000000104fa0ef4 chromedriver + 478964\n8 chromedriver 0x00000001052f559c chromedriver + 3970460\n9 chromedriver 0x00000001052f96f0 chromedriver + 3987184\n10 chromedriver 0x00000001052ff5b4 chromedriver + 4011444\n11 chromedriver 0x00000001052fa2fc chromedriver + 3990268\n12 chromedriver 0x00000001052d21c0 chromedriver + 3826112\n13 chromedriver 0x0000000105316088 chromedriver + 4104328\n14 chromedriver 0x00000001053161e0 chromedriver + 4104672\n15 chromedriver 0x0000000105325f28 chromedriver + 4169512\n16 libsystem_pthread.dylib 0x00000001a788bfa8 _pthread_start + 148\n17 libsystem_pthread.dylib 0x00000001a7886da0 thread_start + 8\n" - ] - } - ], + "outputs": [], "source": [ - "flights = Scrape(\"MUC\", \"LAX\", \"2023-10-28\", export=True)\n", + "flights = Scrape(\"MUC\", \"LAX\", \"2023-10-28\", export=False)\n", "flights.run_scrape()" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -96,226 +66,203 @@ " \n", " \n", " 0\n", - " 2023-10-28 10:25:00\n", - " 2023-10-29 15:10:00\n", - " [Separate tickets booked together]\n", - " 2265\n", + " 2023-10-28 11:30:00\n", + " 2023-10-28 20:37:00\n", + " [Delta, Virgin Atlantic, KLM]\n", + " 1087\n", " MUC\n", " LAX\n", " 1\n", - " 1450.0\n", - " LGW\n", - " 470\n", + " 195\n", + " DTW\n", + " 681\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526143\n", + " 2023-08-03 12:39:06.491987\n", " True\n", " False\n", - " 110\n", + " 85\n", " \n", " \n", " 1\n", - " 2023-10-28 20:37:00\n", - " 2023-10-28 07:15:00\n", - " [Delta, KLM, Virgin Atlantic]\n", - " 1087\n", + " 2023-10-28 07:00:00\n", + " 2023-10-28 11:50:00\n", + " [KLMDelta]\n", + " 830\n", " MUC\n", " LAX\n", " 1\n", - " 195.0\n", - " DTW\n", - " 671\n", + " 75\n", + " AMS\n", + " 768\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526150\n", + " 2023-08-03 12:39:06.492002\n", " True\n", " False\n", - " 111\n", + " 85\n", " \n", " \n", " 2\n", + " 2023-10-28 07:15:00\n", " 2023-10-28 13:10:00\n", - " 2023-10-28 07:00:00\n", " [Air France, Delta]\n", " 895\n", " MUC\n", " LAX\n", " 1\n", - " 100.0\n", + " 100\n", " CDG\n", - " 676\n", + " 770\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526153\n", + " 2023-08-03 12:39:06.492005\n", " True\n", " False\n", - " 110\n", + " 85\n", " \n", " \n", " 3\n", - " 2023-10-28 11:50:00\n", - " 2023-10-28 07:15:00\n", - " [KLMDelta]\n", - " 830\n", + " 2023-10-28 10:25:00\n", + " 2023-10-29 15:10:00\n", + " [Separate tickets booked together]\n", + " 2265\n", " MUC\n", " LAX\n", " 1\n", - " 75.0\n", - " AMS\n", - " 758\n", + " 1450\n", + " LGW\n", + " 489\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526155\n", + " 2023-08-03 12:39:06.492007\n", " True\n", " False\n", - " 110\n", + " 85\n", " \n", " \n", " 4\n", - " 2023-10-28 18:05:00\n", - " 2023-10-28 07:00:00\n", - " [Air France, Delta]\n", - " 1190\n", + " 2023-10-28 14:50:00\n", + " 2023-10-28 09:55:00\n", + " [KLMDelta]\n", + " 1010\n", " MUC\n", " LAX\n", " 1\n", - " 380.0\n", - " CDG\n", - " 674\n", + " 255\n", + " AMS\n", + " 684\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526157\n", + " 2023-08-03 12:39:06.492009\n", " True\n", " False\n", - " 111\n", + " 86\n", " \n", " \n", " 5\n", - " 2023-10-28 15:24:00\n", - " 2023-10-28 11:50:00\n", - " [KLM, Delta]\n", - " 1044\n", + " 2023-10-28 18:10:00\n", + " 2023-10-28 09:25:00\n", + " [Vueling, Iberia]\n", + " 1035\n", " MUC\n", " LAX\n", - " 2\n", - " NaN\n", - " None\n", - " 675\n", + " 1\n", + " 105\n", + " BCN\n", + " 856\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526159\n", + " 2023-08-03 12:39:06.492011\n", " True\n", " False\n", - " 110\n", + " 86\n", " \n", " \n", " 6\n", - " 2023-10-28 19:59:00\n", - " 2023-10-28 22:00:00\n", - " [KLM, Delta]\n", - " 1029\n", + " 2023-10-28 14:50:00\n", + " 2023-10-28 11:25:00\n", + " [KLMDelta]\n", + " 865\n", " MUC\n", " LAX\n", - " 2\n", - " 3000.0\n", - " min\n", - " 675\n", + " 1\n", + " 110\n", + " AMS\n", + " 883\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526161\n", + " 2023-08-03 12:39:06.492014\n", " True\n", " False\n", - " 111\n", + " 86\n", " \n", " \n", " 7\n", - " 2023-10-28 22:00:00\n", - " 2023-10-30 15:25:00\n", - " [Lufthansa, LOT]\n", - " 3025\n", - " MUC\n", - " LAX\n", - " 2\n", - " NaN\n", - " None\n", - " 787\n", - " typical\n", - " None\n", - " 2023-07-09 18:00:05.526166\n", - " True\n", - " False\n", - " 111\n", - " \n", - " \n", - " 8\n", - " 2023-10-28 21:10:00\n", + " 2023-10-28 18:30:00\n", " 2023-10-28 11:50:00\n", - " [Air France, Delta]\n", - " 885\n", + " [Aer Lingus]\n", + " 965\n", " MUC\n", " LAX\n", " 1\n", - " 80.0\n", - " CDG\n", - " 875\n", + " 125\n", + " DUB\n", + " 959\n", " typical\n", " None\n", - " 2023-07-09 18:00:05.526168\n", + " 2023-08-03 12:39:06.492016\n", " True\n", " False\n", - " 111\n", + " 86\n", " \n", " \n", "\n", "" ], "text/plain": [ - " departure_datetime arrival_datetime airlines \n", - "0 2023-10-28 10:25:00 2023-10-29 15:10:00 [Separate tickets booked together] \\\n", - "1 2023-10-28 20:37:00 2023-10-28 07:15:00 [Delta, KLM, Virgin Atlantic] \n", - "2 2023-10-28 13:10:00 2023-10-28 07:00:00 [Air France, Delta] \n", - "3 2023-10-28 11:50:00 2023-10-28 07:15:00 [KLMDelta] \n", - "4 2023-10-28 18:05:00 2023-10-28 07:00:00 [Air France, Delta] \n", - "5 2023-10-28 15:24:00 2023-10-28 11:50:00 [KLM, Delta] \n", - "6 2023-10-28 19:59:00 2023-10-28 22:00:00 [KLM, Delta] \n", - "7 2023-10-28 22:00:00 2023-10-30 15:25:00 [Lufthansa, LOT] \n", - "8 2023-10-28 21:10:00 2023-10-28 11:50:00 [Air France, Delta] \n", + " departure_datetime arrival_datetime airlines \\\n", + "0 2023-10-28 11:30:00 2023-10-28 20:37:00 [Delta, Virgin Atlantic, KLM] \n", + "1 2023-10-28 07:00:00 2023-10-28 11:50:00 [KLMDelta] \n", + "2 2023-10-28 07:15:00 2023-10-28 13:10:00 [Air France, Delta] \n", + "3 2023-10-28 10:25:00 2023-10-29 15:10:00 [Separate tickets booked together] \n", + "4 2023-10-28 14:50:00 2023-10-28 09:55:00 [KLMDelta] \n", + "5 2023-10-28 18:10:00 2023-10-28 09:25:00 [Vueling, Iberia] \n", + "6 2023-10-28 14:50:00 2023-10-28 11:25:00 [KLMDelta] \n", + "7 2023-10-28 18:30:00 2023-10-28 11:50:00 [Aer Lingus] \n", "\n", - " travel_time origin destination layover_n layover_time layover_location \n", - "0 2265 MUC LAX 1 1450.0 LGW \\\n", - "1 1087 MUC LAX 1 195.0 DTW \n", - "2 895 MUC LAX 1 100.0 CDG \n", - "3 830 MUC LAX 1 75.0 AMS \n", - "4 1190 MUC LAX 1 380.0 CDG \n", - "5 1044 MUC LAX 2 NaN None \n", - "6 1029 MUC LAX 2 3000.0 min \n", - "7 3025 MUC LAX 2 NaN None \n", - "8 885 MUC LAX 1 80.0 CDG \n", + " travel_time origin destination layover_n layover_time layover_location \\\n", + "0 1087 MUC LAX 1 195 DTW \n", + "1 830 MUC LAX 1 75 AMS \n", + "2 895 MUC LAX 1 100 CDG \n", + "3 2265 MUC LAX 1 1450 LGW \n", + "4 1010 MUC LAX 1 255 AMS \n", + "5 1035 MUC LAX 1 105 BCN \n", + "6 865 MUC LAX 1 110 AMS \n", + "7 965 MUC LAX 1 125 DUB \n", "\n", - " price_eur price_trend price_value access_date one_way \n", - "0 470 typical None 2023-07-09 18:00:05.526143 True \\\n", - "1 671 typical None 2023-07-09 18:00:05.526150 True \n", - "2 676 typical None 2023-07-09 18:00:05.526153 True \n", - "3 758 typical None 2023-07-09 18:00:05.526155 True \n", - "4 674 typical None 2023-07-09 18:00:05.526157 True \n", - "5 675 typical None 2023-07-09 18:00:05.526159 True \n", - "6 675 typical None 2023-07-09 18:00:05.526161 True \n", - "7 787 typical None 2023-07-09 18:00:05.526166 True \n", - "8 875 typical None 2023-07-09 18:00:05.526168 True \n", + " price_eur price_trend price_value access_date one_way \\\n", + "0 681 typical None 2023-08-03 12:39:06.491987 True \n", + "1 768 typical None 2023-08-03 12:39:06.492002 True \n", + "2 770 typical None 2023-08-03 12:39:06.492005 True \n", + "3 489 typical None 2023-08-03 12:39:06.492007 True \n", + "4 684 typical None 2023-08-03 12:39:06.492009 True \n", + "5 856 typical None 2023-08-03 12:39:06.492011 True \n", + "6 883 typical None 2023-08-03 12:39:06.492014 True \n", + "7 959 typical None 2023-08-03 12:39:06.492016 True \n", "\n", " has_train days_advance \n", - "0 False 110 \n", - "1 False 111 \n", - "2 False 110 \n", - "3 False 110 \n", - "4 False 111 \n", - "5 False 110 \n", - "6 False 111 \n", - "7 False 111 \n", - "8 False 111 " + "0 False 85 \n", + "1 False 85 \n", + "2 False 85 \n", + "3 False 85 \n", + "4 False 86 \n", + "5 False 86 \n", + "6 False 86 \n", + "7 False 86 " ] }, - "execution_count": 3, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -326,7 +273,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -335,7 +282,7 @@ "'https://www.google.com/travel/flights?q=Flights%20to%20LAX%20from%20MUC%20on%202023-10-28%20oneway&curr=EUR&gl=IT'" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -361,7 +308,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.15" + "version": "3.10.12" }, "orig_nbformat": 4 }, diff --git a/flight_analysis.py b/flight_analysis.py index 3647803..3cd0c1e 100644 --- a/flight_analysis.py +++ b/flight_analysis.py @@ -12,8 +12,8 @@ from datetime import timedelta, datetime import configparser -from src.google_flight_analysis.scrape import Scrape -from src.google_flight_analysis.database import Database +from src.flight_analysis.scrape import Scrape +from src.flight_analysis.database import Database import private.private as private # config diff --git a/src/google_flight_analysis/__init__.py b/src/flight_analysis/__init__.py similarity index 100% rename from src/google_flight_analysis/__init__.py rename to src/flight_analysis/__init__.py diff --git a/src/google_flight_analysis/database.py b/src/flight_analysis/database.py similarity index 100% rename from src/google_flight_analysis/database.py rename to src/flight_analysis/database.py diff --git a/src/google_flight_analysis/flight.py b/src/flight_analysis/flight.py similarity index 100% rename from src/google_flight_analysis/flight.py rename to src/flight_analysis/flight.py diff --git a/src/google_flight_analysis/scrape.py b/src/flight_analysis/scrape.py similarity index 100% rename from src/google_flight_analysis/scrape.py rename to src/flight_analysis/scrape.py