A Python script to scrape football data from FBRef
Project description
FBRef Stats
A python script to scrape football data from FBRef
Check out the documentation
About
FBRef Stats is a Python script which uses BeautifulSoup and requests to scrape data from FBRef. This is a small side project I work on in my free time. As an avid soccer fan and someone who finds sports stats interesting, I tried making a program which takes player stats into account so I could gain an advantage on my fantasy leagues with my friends. However, I could not find many good free libraries which provided soccer data, so I resolved to build one myself.
Installation
As of now, the project is not available as a standalone library. To use this product currently, you can download the script and import it into any other Python scripts you wish to use using:
from fbrefstats import LeagueScraper, GeneralScraper, StatStrings
Usage
As seen above, there are three classes within the fbrefstats script:
(The names of these classes may change in the future, they are currently placeholders)
LeagueScraper- Contains scraping methods relating to leagues. An object is needed to access these methods, with each object representing a specific league.
GeneralScraper- Contains scraping methods that are independant. They are static and do not tie into any specific league.
StatStrings- Class full of variables holding strings, which are used when calling the method
LeagueScraper.getLeagueLeaders()
- Class full of variables holding strings, which are used when calling the method
Check out the documentation for info on how to use the script.
Other libraries used
As of now, the libraries used within this project are:
BeautifulSoup4requestspandasStringIOfake-http-reader| Link to the repo here
To-do
As of right now, this script is still in a very early development phase, and I am only working on it as a personal side project. I have a few things I am thinking of adding:
-
Update
README.md(Urgent) ☑ -
Add a documentation file ☑
-
Update the documentation file ☑
-
Static functions ☑
Split theScraperclass into two classes:LeagueScraperandGeneralScraper, which contains static methods -
Randomized
requestsheaders to avoid detectability when scraping ☑ -
Different table formats ☑
I've learnt that pandas dataframes already have built-in functions for this:pandas.DataFrame.to_csv()andpandas.DataFrame.to_string() -
Turn FBScraper into a library ☐
I have never made an actual library before, so I would like to research how to turn this into a real installable Python library. -
More scraping! ☐
There is so much data available on FBRef, so I would love to add more methods so that this data can be accessed through the script -
Add support for different league formats ☐
As of right now, there are very few leagues supported as I am yet to add functionality to leagues with different formats (promotion/relegation playoffs, MLS post-season, or Apertura/Clausura formats commonly found in Latin America) -
Add nationality argument to
GeneralScraper.getPlayerLink()☐
Currently,GeneralScraper.getPlayerLink()takes one argument:inputted_player_name. The method returns a list of URLs depending on which players were found when searching withinputted_player_name. This can get annoying when there are many players with similar names, so adding a nationality argument would be useful for searching.
License
GNU GPL
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fbrefstats-0.1.10.tar.gz.
File metadata
- Download URL: fbrefstats-0.1.10.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37ab6a88d948bcaa16a50b0a50c2b1a5c57209e6ac0a861decb7eae21ccea407
|
|
| MD5 |
117b80640594bb5548f983770972c18d
|
|
| BLAKE2b-256 |
03ff6a863e9fe8bd9f1bff7f18cc6e8c4e7bfa4bbb18b3366208fa4ddfbfacec
|
File details
Details for the file fbrefstats-0.1.10-py3-none-any.whl.
File metadata
- Download URL: fbrefstats-0.1.10-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac601d515ac75920155c04042f1a6c25956a8dca178b0ff1df920ad769a2d7c4
|
|
| MD5 |
4868ae0a5829906f929f8c744b7e78ae
|
|
| BLAKE2b-256 |
2b06c824a5bf7088d6d2c762eb14f3c625d60d5cef8ee49513e4e9ad9b3dd970
|