andregri / fantacalcio-voti-live

1 stars 1 forks source link

fantacalcio-voti-live

fantacalcio-voti-live is a web dashboard that plots footballer votes over the time. Usually the votes change when events, like penalties, goals, etc, happens during the match.

The dashboard is developed using Python Dash and data are stored in a postgresql database that you can run on docker.

Note: Since season 2023-2024, nodejs and protobufjs are required!

Screenshot of the dashboard: Screenshot of the dashboard

Requirements

Python:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

NodeJS:

npm install protobufjs

Getting started

Run the Postgresql database in a docker container:

sudo docker run --rm -d --name fantacalcio_db -v $(pwd)/var/fantacalcio_pgdata:/var/lib/postgresql/data -e POSTGRES_USER=fantallenatore -e POSTGRES_PASSWORD=password -e POSTGRES_DB=fantacalcio_db -p 5432:5432 postgres

Run the scraper on the football teams that are currently playing and that you want to track:

Run the dashboard:

python3 dashboard.py

Access the dashboard locally at http://127.0.0.1:8050/

Debug the db

Open a bash in the postgresql container:

sudo docker exec -it fantacalcio_db bash

Log into the db:

psql -U fantallenatore -d fantacalcio_db

Show the tables:

select * from giocatore;
select * from voto;

Run the scraper with crontab

To run the scraper automatically, you can edit crontab with a line similar to the following:

25 18 * * * /path/to/your/fantacalcio-voti-live/scraper.sh > ~/fantacalcio.log

ToDo

Take Home