michelmansour / fb-power-rankings

Power Rankings for ESPN Fantasy Baseball
MIT License
11 stars 6 forks source link

Attribute error with Beautiful Soup #9

Open baseballpractice opened 7 years ago

baseballpractice commented 7 years ago

I'm brand new to programming so it's quite possible that the issues I'm having are due to a mistake on my end. That being said, if someone could confirm whether or not the script works for them and hasn't been broken due to a change on ESPN's end that would be amazing!

Here's the error I'm getting:

MyName$ python3 rankings_cli.py Traceback (most recent call last): File "rankings_cli.py", line 192, in <module> main(args) File "rankings_cli.py", line 148, in main rankings = pr.powerRankings() File "/Users/MyName/Downloads/fb-power-rankings-master/fbpowerrankings/power_rankings.py", line 327, in powerRankings oppAwps = self._strengthOfSchedule() File "/Users/MyName/Downloads/fb-power-rankings-master/fbpowerrankings/power_rankings.py", line 283, in _strengthOfSchedule schedule = self._allSchedules() File "/Users/MyName/Downloads/fb-power-rankings-master/fbpowerrankings/power_rankings.py", line 205, in _allSchedules for teamId in self._teamIds(): File "/Users/MyName/Downloads/fb-power-rankings-master/fbpowerrankings/power_rankings.py", line 198, in teamIds teamOptions = soup.find('div', class='bodyCopy').\ AttributeError: 'NoneType' object has no attribute 'find'

michelmansour commented 7 years ago

Hi, thanks for checking out this project!

Are you trying to use it with a public or private league? Unfortunately, ESPN changed their login system a while ago, and I haven't had any time/luck getting through it. Public leagues should work still, but it's possible they've changed how they respond to all requests.

baseballpractice commented 7 years ago

Thanks for replying, it's a very cool project! My league is definitely public. Is the "request-data-from-ESPN" step where the error is coming from?

michelmansour commented 7 years ago

The error seems to be happening when it's trying to get all the team IDs from the schedule page: http://games.espn.go.com/flb/schedule?leagueId=<YOUR_LEAGUE_ID>&seasonId=2017. I was able to find a random public league and test against that, and it worked fine, so I'm not sure what's going on.

Could you share which version of Python you're running?

baseballpractice commented 7 years ago

I'm using Python 3.6.1

michelmansour commented 7 years ago

Could you try changing the version of beautifulsoup4 in requirements.txt to 4.6.0? Then re-install the dependencies (pip install -r requirements.txt), and see if that works.

Apparently, bs4 was broken with Python 3.5 until version 4.4.0 was released. I got a different error than you're seeing when I tried, but maybe this will fix it anyway.

baseballpractice commented 7 years ago

It looks like I already had 4.6.0 installed. I went ahead and uninstalled and reinstalled all the components from requirements.txt, and at least this time I got a different error message :)

File "rankings_cli.py", line 192, in main(args) File "rankings_cli.py", line 148, in main rankings = pr.powerRankings() File "/Users/myname/Documents/Baseball/Power Rankings/fbpowerrankings/power_rankings.py", line 327, in powerRankings oppAwps = self._strengthOfSchedule() File "/Users/myname/Documents/Baseball/Power Rankings/fbpowerrankings/power_rankings.py", line 282, in _strengthOfSchedule records = self._powerMatrix() File "/Users/myname/Documents/Baseball/Power Rankings/fbpowerrankings/power_rankings.py", line 233, in _powerMatrix (totals, pairings) = self._totals() File "/Users/myname/Documents/Baseball/Power Rankings/fbpowerrankings/power_rankings.py", line 410, in _totals return self._cumulativeTotals() File "/Users/myname/Documents/Baseball/Power Rankings/fbpowerrankings/power_rankings.py", line 267, in _cumulativeTotals standingsSoup.findall('tr', class='tableSubHead')[1]. AttributeError: 'NoneType' object has no attribute 'find_all'