Answer the question
In order to leave comments, you need to log in
How to check if a remote url is reachable using Python?
I would like to know how to use Python(3.3) to determine if a certain url address is available to me?
When calling a command urllib.request.urlopen('адрес')
with a non-existent address, an error is generated. How to modify this code, or how it is possible to replace this call so that the program does not stop its work.
Answer the question
In order to leave comments, you need to log in
try:
urllib.request.urlopen('адрес')
except URLError:
print 'Адреса не существует'
Get to know the exceptions mentioned above, a powerful thing to know
Thanks for the help
, only in my example it turns out that you need to do the following:
try:
urllib.request.urlopen('адрес')
except:
print("Oops! That was no valid adress. Try again...")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question