Scraping data from spanish football La Liga website.
This is a tool entirely written in Python that allows to scrap all player data available in the official website of the spanish football league for the current season. At the time of writing, three competitions are available: female first division, male first division and male second division.
Create a Python virtualenv and install requirements:
$ python3.10 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
Optionally, you can create a .env
file in the working directory to overwrite settings from settings.py.
There are few external requirements for the project to work properly:
$ python main.py --help
Usage: main.py [OPTIONS]
Options:
-v, --verbose Loglevel increased to debug.
-n, --num_players INTEGER Num players (per competition) to be scraped. If
0, all available players will be retrieved.
[default: 0]
--help Show this message and exit.
A common usage would be just python main.py -v
. It takes aproximately 2 hours to finish execution (depending on the network issues).
Once finished, a csv file will be present in repo containing all scraped data from players.
- Generated datasets are stored in the datasets folder and updated weekly.
- Files will have a name like
S2122-laliga-players.csv
depending on the football season. - A description of the columns can be found in col-specs.csv.
- Datasets are also available at Kaggle.