How to Scrape NBA Player Stats from NBA.com ?

Benefits of web scraping NBA stats

Accessing accurate and comprehensive NBA player statistics is crucial for basketball enthusiasts, data analysts, and fantasy sports enthusiasts alike. While NBA.com provides a wealth of information, manually gathering player stats can be a time-consuming task. Fortunately, web scraping offers a powerful solution to automate data extraction from NBA.com, allowing you to efficiently gather and analyse NBA player statistics. In this article, we’ll guide you through the process of scraping NBA player stats from NBA.com, equipping you with the skills to unlock valuable insights, track player performance, and take your basketball analysis to the next level

Choosing a web scraping tool

There are numerous web scraping software (both desktop and web applications) available today. You should choose the right one for your requirement. You may refer to this guide to know more. In this article we are going to use WebHarvy to scrape data from NBA.com.

WebHarvy is a very easy to use, point and click web scraping software. You may download and install WebHarvy in your computer. A free 15 days trial version is available.

WebHarvy resembles a web browser that enables you to load and navigate websites seamlessly. With WebHarvy, you have the ability to effortlessly select and extract data from any web page with a simple click on the displayed text or images. The software ensures a quick and easy start to your data scraping endeavours, allowing you to begin extracting valuable information within minutes.

Steps to follow to scrape NBA.com using WebHarvy

  1. Download and install WebHarvy in your computer.
  2. Open WebHarvy and load the page from which you need to scrape data – https://www.nba.com/stats/players/traditional?SeasonType=Playoffs
  3. Start Configuration
  4. Click and select the data which you need to scrape. You can directly click on data like player name, team name, age, PTS, FGM etc. Clicking on any text displayed on the page will bring up a Capture window with various options. Select the Capture Text option to scrape the text of the clicked item. WebHarvy automatically detects repeating patterns of data. So when you click and select the first player name, all subsequent player names will be parsed and selected automatically.
  5. Since the player stats data is displayed in multiple pages, we need to configure pagination.
  6. Here we are going to use JavaScript pagination method.
  7. The code to use to load the next page is given below
  8. Once all required data has been selected and pagination configured, click on Stop Configuration
  9. You may now optionally save the configuration so that it can be edited or run later
  10. Click on the Start Mine button to start mining data using the configuration.
document.getElementsByClassName('Pagination_button__sqGoH')[1].click();

Video : Scraping NBA Stats

Try it yourselves

We recommend that you go ahead and download/install the free 15 days trial version of WebHarvy from our website. To get started, please follow the link below.

Getting started with Web Scraping using WebHarvy