Skip to content
Advertisement

Scraping Sports Data With Beautifulsoup

This is my first-time web scraping with beautiful soup and wanted to do a little project with hockey since I am a huge fan of the sport. I am a little stuck and wondering how to retrieve the header names of the stats for each player.

Here is my current code:

JavaScript

I am currently getting an error that says “ResultSet object has no attribute ‘%s’ for the line

JavaScript

Eventually, I want to get a list of all of the Stat Names being tracked and use that as the columns in a pandas dataframe that lists each player and their corresponding stats.

What’s the best way to achieve this?

Thanks for your help!

Advertisement

Answer

There’s a typo in your headers iteration that’s why you’re getting the error,

JavaScript

I suppose the expected result is as follows.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement