Skip to main content

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

Installation

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

Usage

Code excerpt from __main__.py

from stats_scraper.scraper import Scraper

scraper = Scraper()

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

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):
        break
    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):
        break
    print(rebounds[0], rebounds[1])
    count += 1

Acknowledgment

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

License

MIT

Metadata

Release files for stats-scraper 1.0.0

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

Source distribution (sdist)

Source distribution for stats-scraper 1.0.0
File Size Uploaded
stats_scraper-1.0.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stats-scraper 1.0.0
File Interpreter ABI Platform
stats_scraper-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / stats_scraper-1.0.0.tar.gz

Download URL stats_scraper-1.0.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
43c284426fb45b09d28a452a16d40ec9ad67a9e9128e1b7ad8fd0ea992cc54a2
BLAKE2b-256 checksum
How to use checksums
cd9f7ca636f80d89e391eec20fb7bba823dbfdc6326cc6bd083d022aa19cda7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / stats_scraper-1.0.0-py3-none-any.whl

Download URL stats_scraper-1.0.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1659eea94aa583eb5c3672fa90f21c4a82a51d023e899a68c3374d14203699ed
BLAKE2b-256 checksum
How to use checksums
3b851175ee750b7282e41b798cc8253883fc4945529c237296ad66933dfcc4e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

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