Skip to main content

Python utility to easily scrape NBA stats

Project description

# nba_scrape

An easy-to-use Python utility to scrape professional basketball data off stats.nba.com using Selenium and BeautifulSoup.

## Installation:

pip install nba_scrape

## Usage:

from nba_scrape import NBA

#### Example:

>>> league = NBA()

>>> lebron = league.get_player(‘lebron james’)

>>> lebron.get_stat(‘pts’, ‘2016-17’, playoffs=True)

>>> 32.8

>>> lebron.get_stats([‘pts’, ‘reb’, ‘ast’, ‘ts%’], ‘2015-18’, mode=’playoffs’)

>>> {‘2015-16’: (26.3, 9.5, 7.6, 0.585), ‘2016-17’: (32.8, 9.1, 7.8, 0.649), ‘2017-18’: (34, 9.1, 9, 0.619)}

#### Get an instance of the NBA class:

league = NBA()

#### Get a player:

player = league.get_player(player_name)

OR

player = league.get_player_by_id(id_number)

#### Get a single stat:

player.get_stat(stat_name, season)

#### Get multiple stats (formatted as a dict with tuples as items):

player.get_stats([stat1, stat2, stat3], season_range, mode=mode)

(Possible modes are ‘season’, ‘playoffs’, or ‘both’; ‘season’ is the default.)

## Current functionality:

  1. Compile a list of all NBA players and their IDs when initializing the NBA class.

  2. Easily load all regular season and playoff stats off a player’s career page to a SQLite database. Only the player’s name is required as input.

  3. Retrieve all traditional stats and select advanced ones (such as True Shooting Percentage) via database queries; only the requested stats and seasons are required as input.

  4. Browser-agnostic; uses the best available browser or raises an error if no supported browser is available.

  5. Test suite to ensure correct statistics are returned.

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_scrape-0.56.tar.gz (9.4 kB view details)

Uploaded Source

File details

Details for the file nba_scrape-0.56.tar.gz.

File metadata

  • Download URL: nba_scrape-0.56.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for nba_scrape-0.56.tar.gz
Algorithm Hash digest
SHA256 38f875223329fe04e0e3c40ebaf1860d0f1cf2aa740f91fcd8f75b4b797ecff9
MD5 21566768de188faf3856be9065e6a0c7
BLAKE2b-256 f132fbfc3fab96465d537b4b13889a739057bf3d5b18d9e808731ccd932ed258

See more details on using hashes here.

Supported by

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