22 lines
800 B
Python
22 lines
800 B
Python
import requests
|
|
|
|
def get_request(url, headers, params):
|
|
try:
|
|
response = requests.get(url, headers=headers, params=params)
|
|
response.raise_for_status()
|
|
except requests.exceptions.HTTPError as errh:
|
|
return "An Http Error occurred:" + repr(errh)
|
|
except requests.exceptions.ConnectionError as errc:
|
|
return "An Error Connecting to the API occurred:" + repr(errc)
|
|
except requests.exceptions.Timeout as errt:
|
|
return "A Timeout Error occurred:" + repr(errt)
|
|
except requests.exceptions.RequestException as err:
|
|
return "An Unknown Error occurred" + repr(err)
|
|
|
|
return response
|
|
|
|
def contains(list, filter):
|
|
for x in list:
|
|
if filter(x):
|
|
return True
|
|
return False |