def get_product_info(self, serial, retry=True):
if self.debug:
print '\t[+] Checking possible product "%s"' % serial
timeout = 10
try:
resp = self.requests.get(self.url + '?productId=' + serial, verify=True, timeout=timeout)
msg = 'Status code: %s' % str(resp.status_code)
if str(resp.status_code) == '401':
print '\t[!] HTTP error. Message was: %s' % msg
print '\t[!] waiting for 30 seconds to let the api server calm down'
# suspecting blockage due to to many api calls. Put in a pause of 30 seconds and go on
time.sleep(30)
if retry:
print '\n[!] Retry'
self.get_product_info(serial, False)
else:
return None
else:
return resp.json()
except requests.RequestException as e:
self.error_msg(e)
return None
评论列表
文章目录