Web Scraping NBA Stats in Python

  • Guided Project
  • 2 hours
  • Intermediate
  • Python

Practice web scraping in Python to gather NBA player and team statistics for predicting season MVPs.

Overview

In this project, you'll assume the role of a data analyst working on a machine learning project to predict the NBA's Most Valuable Player (MVP) for a given season. You'll focus on web scraping to gather the necessary data on NBA player and team statistics from 1991 onwards. Using Python libraries like requests, Beautiful Soup, and Selenium, you'll scrape data from multiple web pages, parse the relevant tables, and combine them into unified datasets. This project allows you to apply and enhance your web scraping skills in a practical, sports analytics context. You'll gain experience extracting data from both static and dynamically-loaded web pages. **Objective:** Scrape, parse, and combine multiple seasons of NBA player and team statistics to enable future machine learning analysis for predicting season MVPs.

What You'll Learn

  • Scrape data from the web using the requests library
  • Parse data using the Beautiful Soup library
  • Use Selenium for more advanced web scraping

Before You Start

  • Installing and importing Python packages
  • Manipulating data using Python lists and dictionaries
  • Writing parameterized Python functions
  • Using Python loops and conditionals to control program flow

Project Steps

10 steps

  1. 1 Project Overview
  2. 2 Exploring the Pages to Scrape
  3. 3 Downloading MVP Voting Tables
  4. 4 Parsing and Combining MVP Voting Tables
  5. 5 Downloading Player Stats: A Pitfall of JavaScript Pages
  6. 6 Downloading Player Stats: Scraping JavaScript Pages
  7. 7 Parsing and Combining Player Stats
  8. 8 Downloading Team Data
  9. 9 Parsing and Combining Team Data
  10. 10 Wrapping Up

Join 1M+ data learners on Dataquest.

  1. 1

    Create a free account

  2. 2

    Choose a learning path

  3. 3

    Complete exercises and projects

  4. 4

    Advance your career