APIにアクセスしてjsonを抽出していますが、1時間ごとのリクエスト制限内にとどまるようにしたいのですが、これを行うための最良の方法は何でしょうか?
これは私が要求をするところです:
# 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