Skip to main content

Scrapes NBA player data from basketball-reference.com and has few methods to sort the data

Project description

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

Use pip to install StatsScraper2.0.0

pip install StatsScraper2.0.0

Usage

Code excerpt from __main__.py

from StatsScraper 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

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

StatsScraper-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

StatsScraper-1.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file StatsScraper-1.0.0.tar.gz.

File metadata

  • Download URL: StatsScraper-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for StatsScraper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 79a9f0c1a611e19e18e30d5c5afb09641f4304caf51483e2a72638ba1c3f1fee
MD5 6c57202092dfb5eea968788e4181d8a9
BLAKE2b-256 b01e785348e56b0118284e08f69f251484080c3e9aded5e3b81f428eee7af72b

See more details on using hashes here.

File details

Details for the file StatsScraper-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: StatsScraper-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for StatsScraper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30b09e88b8019eb785e5e6d88e6decbb5a6e09bc1c2dce2487ef04babdf81806
MD5 959a9de717abf6f059d1674be540ba11
BLAKE2b-256 fb6cdabdbfcb834f08c627a62b9712ae4e340bca07ca695a4f86c1b66fe0568b

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