- .NET 9.0
- MariaDB 11.7.2
-
Install
dotnet-efdotnet tool install --global dotnet-ef
-
Run docker compose command:
docker compose up -d mariadb mongodb rabbitmq
-
Create migrations and update the database for all services:
cd scraper && ./migrations.sh
-
Run docker compose command:
docker compose up -d
-
Create venv
cd ./scraper python -m venv venv -
Activate venv
source venv/bin/activate -
Install requirements
pip install -r requirements.txt
-
Set configuration in const.py
example configuration for Rome to anywhere with 0 stops:
FROM = "ROM" # IATA code for Rome FROM_FULL = "Rome" # Full name of the city FROM_COUNTRY = "Italy" # country TO = "anywhere" # destination (iata or anywhere) STOPS = 0 # number of stops (0, 1, 2) START_URL = f"https://www.kayak.com/explore/{FROM}-{TO}?stops={STOPS}" DESTINATION_PATH = "results/destinations.json" FLIGHTS_PATH = "results/flights.json" AIRPORTS_PATH = "results/airports.json" AIRLINES_PATH = "results/airlines.json" PLANES_PATH = "results/planes.json"
-
Run the scraper
python main.py
The scraper will create a folder called
resultsin thescraperfolder. This folder will contain the following files:destinations.json: contains the destinations and their IATA codesflights.json: contains the flights and their detailsairports.json: contains the airports and their detailsairlines.json: contains the airlines and their detailsplanes.json: contains the planes and their details
-
Generate offers
To create parsed offers json for the database, you need to run
sql.dumper.pyfile. This file will insert the above json files into the database and createparsed_flights.jsonfile in theresultsfolder. This file will contain the parsed offers and their details, which are also inserted into the database.If you have different database name, change it in
import_json_to_sql()function insql_dumper.pyfile.
-
Download
./resultsfolder from files server, put it in thescraperfolder -
Comment out the
generate_offers_from_flights()function (so thatparsed_flights.jsonis not replaced by new data) insql_dumper.pyfile. -
Run
sql_dumper.pyto insert data into the databasepython sql_dumper.py
- Make backups of the database tables using
dump.shscript. This script will create a dump of the database tables and save them in thebackupsfolder. The backups will be in the form of.sqlfiles. - To create backups, run the following command:
cd scraper && ./dump.sh
- To restore the backups, run the following command:
cd scraper && ./dump.sh --restore
Selenium tests are located in tests folder. To run the tests, execute the following command:
pip install -r requirements.txt
python main.py <num_of_bookings>