Closed gyerli closed 8 years ago
it's because of the user-agent not the referer. It was fixed a few days a go but I think it's not up in pypi yet. You might want to try to clone the repo instead.
Actually you are right it is the referer.
There are also issues with the TeamList and Player functions. They seem to be due to the '_endpoint' definitions in the classes. For the TeamList class, the true URL doesn't have the forward slash after 'commonteamyears'. I tried hard coding in the endpoint as 'commonteamyears?&LeagueID=00', but then the issue is the forward slash at the end of the request. The link to the JSON file for the TeamList class should be: 'http://stats.nba.com/stats/commonteamyears?&LeagueID=00'.
I believe that removing the final '/' from the 'BASE_URL' constant in the init.py should fix this, but I'm not sure of the repercussions on the rest of the functions.
I played around with different requests using the altered 'BASE_URL' and everything seems to work again.
+1, but it seems to be fixed in git master branch.
For now, you can install it directly from git, instead of PyPI v0.1a1
version, with pip install git+https://github.com/seemethere/nba_py.git
command.
Yeah, I created a pull request with it fixed and seemethere merged it in. Thanks for the github install method!
Hello, I am very new to all of this and attempting to utilize this. I am running into a similar issue and was wondering if someone could give some details on how I could fix the problem? I installed the api using the pip command and I have all of that, but I am receiving the same "requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://stats.nba.com/stats/playergamelog?Season=2015-16&SeasonType=Regular+Season&PlayerID=2744&LeagueID=00" error when trying any of the examples and my own. However, when I click the link in the error it takes me to a page filled with the requested stats. Any help would be much appreciated.
@siebenecka Did you install it via pip install git+https://github.com/seemethere/nba_py.git
command? Could you share the code that you're using?
Oh my, I had to reinstall git and allow it to use command prompt...now it works after uninstalling the api and reinstalling with that command! Now I just need to mess around with it and get what I need, thanks for the help!
Awesome - here's my usage if anyone's interested (getting all the players, their base stats and photos).
Awesome usage @pawelad! I'll add it to a list of cool things made with nba_py!
Awesome library @seemethere ; - )
Thanks, I've actually been kicking the idea for some time, but seeing your library made me finally sit down and do it : )
And let me know if/when you'll need help with something nba_py
related. For example I've been thinking about creating a PR with player's photo URL's, but wasn't sure if it's a bit 'beyond' NBA Stats API.
No if you have a good idea let it fly!
It is b/c invalid referrer. Possible solution is to add a user agent and referrer to request header. e.g.
headers = {'User-agent': 'Mozilla/5.0', 'referer': 'http://stats.nba.com/scores/'}