Skip to main content

Scrapes NBA player data from and has few methods to sort the data

Project description

A simple CLI python web scraper that scrapes NBA player data from and allows players to be sorted by points, rebounds, and assists and displayed.


Save the .py files under Stats-Scraper and run it with python3. See requirements.txt for any module requirements and install them with pip

Or use pip to install stats_scraper directly

pip install stats_scraper


Code excerpt from

from stats_scraper.scraper import Scraper

scraper = Scraper()

result = scraper.find_player_by_name("Ivica Zubac")
print("Printing result\n")
for p in result:

sorted_points = scraper.sort_by_points("SG")
print("========Printing top scorers========\n")
for scores in sorted_points:
    print(scores[0], scores[1])

sorted_assists = scraper.sort_by_assists("PF")
print("\n\n\n=========Printing top 10 assisters========\n")
count = 0
for assists in sorted_assists:
    if(count >= 10):
    print(assists[0], assists[1])
    count += 1

sorted_rebounds = scraper.sort_by_rebounds("PG", "SG")
print("\n\n\n=========Printing top 20 rebounders========\n")
count = 0
for rebounds in sorted_rebounds:
    if(count >= 20):
    print(rebounds[0], rebounds[1])
    count += 1


Thank you to Oscar Sanchez’s article “Web Scraping NBA Stats” for part of the scraping code



Project details

Download files

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

Files for stats-scraper, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size stats_scraper-1.0.0-py3-none-any.whl (4.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size stats_scraper-1.0.0.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page