Skip to main content

FBRef Stats

A python script to scrape football data from FBRef

Version PyPI Downloads Python License

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 analysing the performance of different players. However, I could not find many good free libraries which provided soccer data, so I resolved to build one myself.

Installation

To install this project, input the following into the command line:

pip install fbrefstats

From there, you can import the package into your program 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()

Check out the documentation for info on how to use the script.

Dependencies

As of now, the libraries used within this project are:

  • BeautifulSoup4
  • requests
  • pandas
  • fake-http-reader | Link to the repo here
  • lxml
  • html5lib

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 ☑

  • Randomized requests headers to avoid detectability when scraping ☑

  • Different table formats (string or csv instead of pandas) ☑ (ALREADY EXISTS)

  • Upload FBRefStats to PyPI ☑

  • 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)

  • Narrow down 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 with inputted_player_name. This can get annoying when there are many players with similar names, so adding a nationality argument, or any other similar optional arguments, would be useful for searching.

License

GNU GPL

Metadata

Release files for fbrefstats 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fbrefstats 0.1.13
File Size Uploaded
fbrefstats-0.1.13.tar.gz 147.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fbrefstats 0.1.13
File Interpreter ABI Platform
fbrefstats-0.1.13-py3-none-any.whl Python 3 none any Details

Total release size: 169.6 kB

Release files / fbrefstats-0.1.13.tar.gz

Download URL fbrefstats-0.1.13.tar.gz
Size 147.7 kB
Tags Source
SHA-256 checksum
How to use checksums
61bea85dc9516601e1e8e53975a4b6bcbb8797f62a5e4081117ef3d04f3511c6
BLAKE2b-256 checksum
How to use checksums
c456cc116bc314c687d8f6eab52764470c7ce1ccdc29c5569be37ee435157a33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0

Release files / fbrefstats-0.1.13-py3-none-any.whl

Download URL fbrefstats-0.1.13-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
428902d8c8125681c05a71bb9e81af95c6b3d8cbd6281a1715dda7347003db9d
BLAKE2b-256 checksum
How to use checksums
bd1d78e8d4a2a5cbbe812200b8523fab2353beadcbffa8ab910d039b001edf7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page