Skip to main content

NBA Data Scraper

Introduction

NBA Data Scraper is a Python library designed to scrape game shots data from a specific basketball-related website (Basketball Reference). It is structured to handle requests efficiently and respectfully using rate limiting to avoid overloading the server (bot traffic). On that note, all use of data acquired should respect the website's terms of use.

📂 Structure

nba-data-scraper/
│
├── nba-data-scraper/
│ ├── init.py
│ ├── utils/
│ │ ├── init.py
│ │ └── _logger.py
│ ├── _abstract.py
│ ├── _data_scraper.py
│ └── scraper.py
│
├── tests/
│ ├── init.py
│ └── ...
│
├── docs/
│ └── ...
│
├── examples/
│ └── ...
│
├── .gitignore
├── LICENSE
├── README.md
├── requirements.txt
└── setup.py

🔧 Installation

pip install nba-data-scraper

Usage

Scrape Player Data

from nba_data_scraper import NBAScraper
nba_scraper = NBAScraper()

# Scrapes player data for the letter 'a'
player_data = nba_scraper.scrape_player_data('a')  

Scrape Schedule Data

# Scrapes games played in a specific year and month
schedule_data = nba_scraper.scrape_schedule_data(year='2023', month='january') 

# Scrapes games played in given list of years and months
schedule_data = nba_scraper.scrape_schedule_data(year=['2022','2023'], month=['january','february'])

# Scrapes all games played given a start and end year
schedule_data = nba_scraper.scrape_all_schedule_data(start_year=2020, end_year=2021)

Scrape Game Data

# Scrapes Game Data for games played within a schedule

## First: Scrape for schedule
schedule_data = nba_scraper.scrape_schedule_data(year='2023', month='january')

## Second: use return DataFrame as input to scrape_game_data method
game_data = nba_scraper.scrape_game_data(schedule_df=schedule_data)

License

See the LICENSE file for details.

Metadata

Release files for nba-data-scraper 1.0.1

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

Source distribution (sdist)

Source distribution for nba-data-scraper 1.0.1
File Size Uploaded
nba_data_scraper-1.0.1.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nba-data-scraper 1.0.1
File Interpreter ABI Platform
nba_data_scraper-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / nba_data_scraper-1.0.1.tar.gz

Download URL nba_data_scraper-1.0.1.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7508c82e13d8fc73ea6bd981e911c8ab0a10864f1888eda310ac5074cff044c8
BLAKE2b-256 checksum
How to use checksums
7d79b195600aef9441523cb231bc3cb526f1912f6de8ffb9970c6de0265f186f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.9.12 Windows/10

Release files / nba_data_scraper-1.0.1-py3-none-any.whl

Download URL nba_data_scraper-1.0.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d67f4a92a589718d6522ec49a71159d5c673aab9c80bd746c222373670abb7f
BLAKE2b-256 checksum
How to use checksums
9e6a282a8d2d87e6685fd56f1875f9e9542d80ec5e8ed77c4d879fe60416119f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.9.12 Windows/10

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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