savvastj / nbashots

NBA shot charts using matplotlib, seaborn, and bokeh.
BSD 3-Clause "New" or "Revised" License
164 stars 36 forks source link

HTTP Error when looking at shots #2

Open gman2691 opened 7 years ago

gman2691 commented 7 years ago

When I type in shots=nba.Shots() I get an 400 Client Error. Bad request for URL. What should I do. Should I update the URL.

UriAceves commented 7 years ago

Same here, I get this error

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-23-a19d83f98491> in <module>()
----> 1 shots = nba.Shots()

.../anaconda/lib/python3.6/site-packages/nbashots/api.py in __init__(self, player_id,
 team_id, league_id, season, season_type, game_id, outcome, location, month, season_segment,
 date_from, date_to, opp_team_id, vs_conference, vs_division, position, rookie_year, game_segment, 
period, last_n_games, clutch_time, ahead_behind, point_diff, range_type, start_period, end_period, 
start_range, end_range, context_filter, context_measure)
    214         self.response = requests.get(self.base_url, params=self.url_paramaters,
    215                                      headers=HEADERS)
--> 216         self.response.raise_for_status()
    217 
    218     def get_shots(self):

/Users/wejoysearch2/anaconda/lib/python3.6/site-packages/requests/models.py in raise_for_status(self)
    891 
    892         if http_error_msg:
--> 893             raise HTTPError(http_error_msg, response=self)
    894 
    895     def close(self):

HTTPError: 400 Client Error: Bad Request for url: http://stats.nba.com/stats/shotchartdetail?
LeagueID=00&Season=2015-
16&SeasonType=Regular+Season&TeamID=0&PlayerID=0&GameID=&Outcome=&Location=&Month=0
&SeasonSegment=&DateFrom=&DateTo=&OpponentTeamID=0&VsConference=&VsDivision=&Position
=&RookieYear=&GameSegment=&Period=0&LastNGames=0&ClutchTime=&AheadBehind=&PointDiff=
&RangeType=&StartPeriod=&EndPeriod=&StartRange=&EndRange=&ContextFilter=&ContextMeasure
=FGA

Nevermind buddy (@gman2691) just rename in nbashots/api.py the variable position to `PlayerPosition, after that it works like a charm. I will send a correction to the main package.