ESPN is one of the leading sports networks and gets millions of views each year from all of the sporting events they host. They even have their own streaming service.

ESPN show the most recent sports news, scores and stats for multiple professional sports leagues like NFL, NBA, Soccer, MLB and a lot more.

Today, we’ll teach you how to scrape NBA stats from ESPN using a free web scraper.

Let’s get started!

Scraping leading NBA scorers stats from ESPN

For this example, we are going to scrape the top NBA scorers in the league. We will also extract their team, ESPN URL profile, average points, fg%, ft% and turnovers for the 2020 - 2021 season.

To get started, you will need to download a free web scraper. For this project, we will be using ParseHub. It’s easy to use, cloud-based scraping, multiple export options, and many more.

Download Prasehub For free

You can use this link if you want to follow along with this project

  1. Once ParseHub is downloaded and installed. Click on the new project button and submit the URL into the text box. The website will now render inside the app.
ESPN rendering inside of ParseHub

2. A select command will automatically be created. While using the select command, click on the first player that is on the page. You should notice the player you’ve selected will be in green. ParseHub will now suggest which other player names you want to extract in yellow.

Selecting NBA player names

3. Click on the next player that is in yellow to select them all. You may need to do this 2-3 times to teach ParseHub what to extract. The rest of the players will now be highlighted in green.

4. On the left sidebar rename your player selection to something more appropriate, let’s name it “player_name”. You should notice that Parsehub is extracting the player name and profile URL.

5. Click on the PLUS (+) sign next to the “player_name” selection and choose the relevant select command.

6. Click on the first player’s name that is highlighted in orange, then click on their position. An arrow will appear showing the association you have created. You may need to repeat this step to fully train the Web scraper. Rename your selection to “Position”.

7. Repeat steps 5-6 to extract stats like Minutes, Points, FG% 3P%, FT% and TO.

Your final project should look like this:

ESPN Web scraping Project

Feel free to extract the other stats, but for this project, these are the stats that we will be extracting.

Running your ESPN web scraping project

Now it’s time to run your scrape project. To do this, click on the green Get Data button on the left sidebar. Here you will be able to test, schedule, or run your scrape job.

For larger projects, we recommend that you always test your scrape project before running it. In this case, we will run it right away.

Exporting ESPN Stats

Once your run is completed, you will be able to download it as an Excel or JSON file.

Closing thoughts

Scraping sports stats from ESPN can help with your research for case studies or finding the best players for your fantasy team.

The great thing about ESPN is there are multiple stats from different sports. So, you can apply this project to extract NFL, NHL, MLB or any other major sports league to extract stats.

How will you use the extracted sports data?

Download ParseHub for Free