A Python client for scraping stats and data from Basketball Reference
Project description
basketball_reference_scraper
Basketball Reference is a resource to aggregate statistics on NBA teams, seasons, players, and games. This package provides methods to acquire data for all these categories in pre-parsed and simplified formats.
Installing
Via pip
I wrote this library as an exercise for creating my first PyPi package. Hopefully, you find it easy to use. Install using the following command:
pip install basketball-reference-scraper
Via GitHub
Alternatively, you can just clone this repo and import the libraries at your own discretion.
Selenium
This package can also capture dynamically rendered content that is being added to the page via JavaScript, rather than baked into the HTML. To achieve this, it uses Python Selenium. Please refer to their installation instructions and ensure you have Chrome webdriver installed in and in your PATH
variable.
Wait, don't scrapers like this already exist?
Yes, scrapers and APIs do exist. The primary API used currently is for stats.nba.com, but the website blocks too many requests, hindering those who want to acquire a lot of data. Additionally, scrapers for Basketball Reference do exist, but none of them load dynamically rendered content. These scrapers can only acquire statically loaded content, preventing those who want statistics in certain formats (for example, Player Advanced Stats Per Game).
Most of the scrapers use outdated methodologies of scraping from 'https://widgets.sports-reference.com/'
. This is outdated and Basketball Reference no longer acquires their data from there. Additionally, Sports Reference recently instituted a rate limiter preventing users from making an excess of 20 requests/minute. This package abstracts the waiting logic to ensure you never hit this threshold.
API
Currently, the package contains 5 modules: teams
, players
, seasons
, box_scores
, pbp
, shot_charts
, and injury_report
.
The package will be expanding to include other content as well, but this is a start.
For full details on the API please refer to the documentation.
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
File details
Details for the file basketball_reference_scraper-2.0.0.tar.gz
.
File metadata
- Download URL: basketball_reference_scraper-2.0.0.tar.gz
- Upload date:
- Size: 46.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64465aae00f77c73ca2940d810e9311a091b6335fac63b467417c55a33b5674a |
|
MD5 | edb13cadc80685ba526b42cc405207f5 |
|
BLAKE2b-256 | 1955e47c7b646366359413bcd798962a2aa6629cf9404c12e01cc69fc4cce4aa |
File details
Details for the file basketball_reference_scraper-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: basketball_reference_scraper-2.0.0-py3-none-any.whl
- Upload date:
- Size: 51.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6567096ce632a645f36f8956230b93814d16dd1339710be74eb952428e0c2ab5 |
|
MD5 | 2846129948fa0a0e4f7c8ae4215a98ca |
|
BLAKE2b-256 | bd874ccef2cf6882d1e62ea4c901725250fc5c61400604053ab9cc72a511c509 |