Skip to content

Commit

Permalink
simplify url_is_alive
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Sep 15, 2023
1 parent 6f5880b commit 218a70d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions esupy/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ def url_is_alive(url):
"""
with requests.Session() as s:
try:
response = s.get(url)
response = s.get(url, headers=headers)
response.raise_for_status()
return True
except requests.exceptions.HTTPError:
response = s.get(url, headers=headers)
try:
response.raise_for_status()
return True
except requests.exceptions.HTTPError:
return False
except requests.exceptions.RequestException:
except requests.exceptions.HTTPError as err:
print(err)
return False
except requests.exceptions.RequestException as err:
print(err)
return False
else:
return False

0 comments on commit 218a70d

Please sign in to comment.