Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Getting errors #25

Closed
troytreynolds opened this issue Mar 30, 2016 · 2 comments
Closed

Getting errors #25

troytreynolds opened this issue Mar 30, 2016 · 2 comments

Comments

@troytreynolds
Copy link

Below are the errors I am getting from the tests folder:

from nba_py import player
from nba_py.player import get_player
def test():
pid = get_player('Tim', 'Duncan')
vs_pid = get_player('Stephen', 'Curry')
assert player.PlayerList()
assert player.PlayerSummary(pid)
assert player.PlayerGeneralSplits(pid)
assert player.PlayerOpponentSplits(pid)
assert player.PlayerLastNGamesSplits(pid)
assert player.PlayerInGameSplits(pid)
assert player.PlayerClutchSplits(pid)
assert player.PlayerShootingSplits(pid)
assert player.PlayerPerformanceSplits(pid)
assert player.PlayerYearOverYearSplits(pid)
assert player.PlayerCareer(pid)
assert player.PlayerProfile(pid)
assert player.PlayerGameLogs(pid)
assert player.PlayerShotTracking(pid)
assert player.PlayerReboundTracking(pid)
assert player.PlayerPassTracking(pid)
assert player.PlayerDefenseTracking(pid)
assert player.PlayerShotLogTracking(pid)
assert player.PlayerReboundLogTracking(pid)
assert player.PlayerVsPlayer(pid, vs_pid)

test()


Traceback (most recent call last):
File "C:/Users/Troy/PycharmProjects/nbastats/nbaStatsLebron.py", line 29, in
test()
File "C:/Users/Troy/PycharmProjects/nbastats/nbaStatsLebron.py", line 6, in test
pid = get_player('Tim', 'Duncan')
File "C:\Users\Troy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nba_py\player.py", line 11, in get_player
pl = PlayerList(season=season, only_current=only_current).info()
File "C:\Users\Troy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nba_py\player.py", line 28, in init
'IsOnlyCurrentSeason': only_current})
File "C:\Users\Troy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\nba_py__init__.py", line 42, in _get_json
_get.raise_for_status()
File "C:\Users\Troy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\models.py", line 840, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://stats.nba.com/stats/commonallplayers/?LeagueID=00&IsOnlyCurrentSeason=0&Season=2014-15

Is there something that I need to setup in order for this to work?

@rmartin48
Copy link

stats.nba.com is rejecting the Python User Agent but this has been fixed by emulating a normal browser
HEADERS = {'user-agent': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/45.0.2454.101 Safari/537.36'), 'referer': 'http://stats.nba.com/scores/' }

Uninstall nba_py, clone latest source code from master branch and reinstall. Installing via pip gave me the same error.

@troytreynolds
Copy link
Author

Perfect that worked! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants