Added exception handling during get
This commit is contained in:
parent
a9a07aabea
commit
5ca786b1ae
10
main.py
10
main.py
|
@ -21,8 +21,14 @@ while not urls.empty():
|
||||||
|
|
||||||
# Perform request
|
# Perform request
|
||||||
print("Fetching url '%s'..."%url, end="")
|
print("Fetching url '%s'..."%url, end="")
|
||||||
r = session.get(url)
|
try:
|
||||||
print("\tdone")
|
r = session.get(url)
|
||||||
|
print("\tdone")
|
||||||
|
except Exception as e:
|
||||||
|
print("\tfailed")
|
||||||
|
print(e)
|
||||||
|
finally:
|
||||||
|
r.close()
|
||||||
|
|
||||||
# Read response
|
# Read response
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
|
|
Loading…
Reference in New Issue