A simple CLI program to find promotional tickets in cp.pt
Below are presented 2 alternative methods to use this program.
The first one will run the program inside a docker container and is the recommended way to use this program, since you don't have to care about meeting dependencies locally, other than having Docker installed.
The second method will get you a copy of the project up and running on your local machine. This program was developed and tested on a macOS High Sierra, using python 3.6.5.
About the usage of this program, it will request a search for each applicable day on cp.pt website, using the parameters specified (e.g. origin station and destination) and, after submitting a new search for each day, will print all promotional tickets found that match the specified filters.
- Install Docker for your OS.
- Pull the latest Docker image from Docker Hub, with
docker pull jpdias92/promo-cp
- Alternatively, build the image from the Dockerfile with
docker build -t promo-cp .
- Alternatively, build the image from the Dockerfile with
- Run the image you built on last step with
docker run -it promo-cp
- You can check the available options and example usage with
docker run promo-cp -h
- Python 3 (developed using python 3.6.5). Check with
python --version
orpython3 --version
. - Chromedriver - The web driver used. Ensure that chromedriver is in your path.
- Google Chrome.
There is an install.sh script that will start a virtual environment (venv) and install the project's dependencies, selenium and bs4. Using this script:
- Run the install script:
./install.sh
- Activate the virtual environment:
source venv/bin/activate
. To stop using the venv typedeactivate
- You can try the program using default parameters with the command
python promo_cp.py
- You can check the available options and example usage with
python promo -h
- Search for trips from Lisboa Oriente to Vila Nova de Gaia, on Fridays, with departure time between 16h and 21h
docker run -it jpdias92/promo-cp -o "Lisboa - Oriente" -d "Vila Nova de Gaia-Devesas" -w 4 -hl 16 -hu 21
- PyCharm - The IDE used
- Selenium package for python - Python language bindings for Selenium WebDriver
- Chromedriver - WebDriver for Chrome
- Docker
- Joao Dias - jpdias92
This project is licensed under the MIT License - see the LICENSE.md file for details