我正在使用python调用Last.fm API来获取用户信息。获取大约7000个用户后会发生此错误:
Traceback (most recent call last):
File "C:/Python27/My Codes & Data/scanuserinfo_100K_3.py", line 48, in <module>
r=requests.get(host,params=params)
File "C:\Python27\requests\api.py", line 60, in get
return request('get', url, **kwargs)
File "C:\Python27\requests\api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\requests\sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\requests\sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\requests\adapters.py", line 407, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine("''",))
以下是我调用API的代码:
import requests
API_KEY='####my api key input here#####'
host='http://ws.audioscrobbler.com/2.0/'
params={'method':'user.getInfo',
'user':'###userid input here####',
'api_key':API_KEY
}
r=requests.get(host,params=params)
有人可以帮助我吗?
答案 0 :(得分:1)
它可能与他们的API限制有关,因为他们希望你不要超过5个电话/秒* 60秒/分钟* 5分钟= 1500个电话/ 5分钟
4.4您将根据随Web服务响应发送的HTTP标头实施适当的缓存。你不会超过5 每秒发送一次IP地址的请求,平均超过5 分钟期限,未经事先书面同意。你同意缓存 类似的艺术家和任何图表数据(顶级曲目,顶级艺术家,顶级 专辑)至少一周。