api에 액세스하고 json을 추출 중이지만 시간 제한 요청 제한 내에 머물러 있는지 확인하려면이 작업을 수행하는 가장 좋은 방법은 무엇입니까? 내가 요청하기Python : 시간당 URL 요청을 확인하십시오.
이 : 당신은 token bucket algorithm을 사용할 수
# return the json
def returnJSONQuestion(id):
url = 'http://someApi.com?index_id={0}&output=json'
format_url = url.format(id)
try:
urlobject = urllib2.urlopen(format_url)
jsondata = json.loads(urlobject.read().decode("utf-8"))
print jsondata
shortRandomSleep()
except urllib2.URLError, e:
print e.reason
except(json.decoder.JSONDecodeError,ValueError):
print 'Decode JSON has failed'
return jsondata