I\'ve been trying to figure out what the best way to validate a URL is (specifically in Python) but haven\'t really been able to find an answer. It seems like there isn\'t o
you can also try using urllib.request
to validate by passing the URL in the urlopen
function and catching the exception for URLError
.
from urllib.request import urlopen, URLError
def validate_web_url(url="http://google"):
try:
urlopen(url)
return True
except URLError:
return False
This would return False
in this case