Skip to main content

A tool to scrape a basketball website for player, schedule, and game data. Legal implications apply. Please look at README.md for more information.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nba_data_scraper-1.0.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nba_data_scraper-1.0.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file nba_data_scraper-1.0.1.tar.gz.

File metadata

  • Download URL: nba_data_scraper-1.0.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.12 Windows/10

File hashes

Hashes for nba_data_scraper-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7508c82e13d8fc73ea6bd981e911c8ab0a10864f1888eda310ac5074cff044c8
MD5 53baae4fa65f0a657e0c7918221f99ae
BLAKE2b-256 7d79b195600aef9441523cb231bc3cb526f1912f6de8ffb9970c6de0265f186f

See more details on using hashes here.

File details

Details for the file nba_data_scraper-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: nba_data_scraper-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.9.12 Windows/10

File hashes

Hashes for nba_data_scraper-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d67f4a92a589718d6522ec49a71159d5c673aab9c80bd746c222373670abb7f
MD5 f53e0cc519c1945eb621b55133195e80
BLAKE2b-256 9e6a282a8d2d87e6685fd56f1875f9e9542d80ec5e8ed77c4d879fe60416119f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page