Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _req(self, payload):
try:
r = requests.get(self._url(), params = payload, headers = make_ua(self.mailto, self.ua_string))
r.raise_for_status()
except requests.exceptions.HTTPError:
try:
f = r.json()
raise RequestError(r.status_code, f['message'][0]['message'])
except:
r.raise_for_status()
except requests.exceptions.RequestException as e:
print(e)
check_json(r)
return r.json()
else:
endpt = url + str(ids[i])
endpt = endpt.strip("/")
try:
r = requests.get(endpt, params = payload, headers = make_ua(mailto, ua_string))
r.raise_for_status()
except requests.exceptions.HTTPError:
if is_json(r):
raise RequestError(r.status_code, parse_json_err(r))
else:
r.raise_for_status()
except requests.exceptions.RequestException as e:
raise e
check_json(r)
js = r.json()
coll.append(js)
if len(coll) == 1:
coll = coll[0]
return coll