-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi,
Thanks for your work as it is very useful. Why do you make a second request if the first one works?
try:
res = requests.get(url, timeout=timeout, headers=headers)
except (ConnectionError, HTTPError, Timeout, TooManyRedirects):
raise URLUnreachable("The URL does not exist.")
except MissingSchema: # if no schema add http as default
url = "http://" + url
# throw URLUnreachable exception for just incase
try:
res = requests.get(url, timeout=timeout, headers=headers)
except (ConnectionError, HTTPError, Timeout, TooManyRedirects):
raise URLUnreachable("The URL is unreachable.")
Also, you can reduce the rate of failure of the first block if you check for schema before any request is made (with a regex). Which would therefore allow you to merge the 2 blocks in one...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels