0

I just got an ESPN API key, and have just started to try to use it. However, when I try to call it, I get a 403 error, which means the servers think I have already called the data too many times today. To clarify, my limit is 7,500 calls per day. My code is extremely simple, just seeing what data comes back:

import requests
print(requests.get('http://api.espn.com/:version/sports?apikey=:apikey'))

The API key is correct, and for extra detail I am using the Spyder API.

4

1 回答 1

0

这是我的工作解决方案:

Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> version = 'v1'
>>> apikey = '[YOUR KEY HERE]'
>>> print(requests.get('http://api.espn.com/' + version + '/sports?apikey=' + apikey))
<Response [200]>
>>>

这也有效:

Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> url = 'http://api.espn.com/v1/sports'
>>> params = dict(
...     apikey = '[YOUR KEY HERE]'
... )
>>> print(requests.get(url=url, params=params))
<Response [200]>
>>>
于 2014-09-18T18:04:01.323 回答