roclark / sportsipy

A free sports API written for python
MIT License
475 stars 189 forks source link

NFL Boxscore Returning No Values #788

Closed michael-abbate closed 8 months ago

michael-abbate commented 9 months ago

Bug When calling Boxscore properly to return boxscores for NFL games, no games are returned.

To Reproduce Sample code which causes an issue.

Boxscores(5,2023).games

Expected behavior We expected values like the following to come through:

{'5-2023': [{'boxscore': '202310050was', 'away_name': 'Chicago Bears', 'away_abbr': 'chi', 'away_score': 40, 'home_name': 'Washington Commanders', 'home_abbr': 'was', 'home_score': 20, 'winning_name': 'Chicago Bears', 'winning_abbr': 'chi', 'losing_name': 'Washington Commanders', 'losing_abbr': 'was'}, {'boxscore': '202310080buf', 'away_name': 'Jacksonville Jaguars', 
...

I was able to reproduce the problem manually by passing in the kwarg url into pyquery (pq).

Additional context PyQuery accepts kwargs. In this case, the kwarg url was needed to parse the HTML properly. Otherwise, it was attempting to parse the URL string we were passing through as HTML.

davidjkrause commented 9 months ago

Took a look at your issue. As with most recent issues here, these cases are resolved by my fork at https://github.com/davidjkrause/sportsipy

See my similar comment on most of the recent issues, this particular repo seems no longer maintained.

Following is what is returned using the fork mentioned above.

>>> from sportsipy.nfl.boxscore import Boxscores
>>> Boxscores(5,2023).games
{'5-2023': [{'boxscore': '202310050was', 'away_name': 'Chicago Bears', 'away_abbr': 'chi', 'away_score': 40,  ...
JesusC10 commented 8 months ago

Bug Report Even when using the fork at https://github.com/davidjkrause/sportsipy I'm not getting any values from it

Description of the Problem: When calling Boxscores to retrieve NFL game boxscores, no games are returned as expected.

To Reproduce:

Sample code that causes the issue:

from sportsipy.nfl.boxscore import Boxscores

games_today = Boxscores(5, 2023)
print(games_today.games)

Returned value

{'5-2023': []}

Expected Value

{'5-2023': [{'boxscore': '202310050was', 'away_name': 'Chicago Bears', 'away_abbr': 'chi', 'away_score': 40, 'home_name': 'Washington Commanders', 'home_abbr': 'was', 'home_score': 20, 'winning_name': 'Chicago Bears', 'winning_abbr': 'chi', 'losing_name': 'Washington Commanders', 'losing_abbr': 'was'}, {'boxscore': '202310080buf', 'away_name': 'Jacksonville Jaguars', 
davidjkrause commented 8 months ago

Not really sure why that would be. Did you use all the dependencies in requirements.txt from the fork, it has a few differences from this package. The sample code you provided works when I test it.

JesusC10 commented 8 months ago

Yes, I followed the installation process for the fork. I got the .whl file did the pip install and i got the sportsipy-0.6.0 version installed. I'm not sure if i did something wrong during the process but I dont think so, the instructions where really clear.

Note Before this i did

pip install sportsipy

I dont know if that could be the error

davidjkrause commented 8 months ago

That could be the issue. I did only these steps using a virtualenv to confirm the fork works:

pyenv virtualenv 3.10.10 sportsipy_test
pyenv activate sportsipy_test
pip install git+https://github.com/davidjkrause/sportsipy@master
python3

>>> from sportsipy.nfl.boxscore import Boxscores
>>> Boxscores(5,2023).games
{'5-2023': [{'boxscore': '202310050was', 'away_name': 'Chicago Bears' ...
JesusC10 commented 8 months ago

Okay, i'll try deleting all that is related to sportsipy and then install the fork

pip install git+https://github.com/davidjkrause/sportsipy@master

if that doesnt work, i´ll try the virtualenv and let you know what happend so you are aware of the solution.

michael-abbate commented 8 months ago

Thanks David. Jesus, setting up a virtualenv and pip installing worked for me. Seems like the easiest and cleanest solution here.

I also realized that if you run too many requests too quickly you will start to receive a 429 error: https://www.sports-reference.com/bot-traffic.html

davidjkrause commented 8 months ago

Definitely can get 429s using this package rapidly, there was another issue discussing it, and personally I don't think it's a good idea to put any throttling in the package itself, the program using the package will need to consider it.

I've found that having a 30 second delay between requests works, and I don't get throttled, just have to be patient collecting larger amounts of data.

JesusC10 commented 8 months ago

It was a simple solution. Im using an anaconda environment so i did unistall it there and just installed the fork and it worked. It appeard that there was a overlaping of both installations so if anyone installed the earlier version just uninstall it and install the latest stable version.

Thanks @davidjkrause and @michael-abbate for the responses