Skip to content

Instantly share code, notes, and snippets.

@vital101
Created October 22, 2012 12:42
Show Gist options
  • Save vital101/3931327 to your computer and use it in GitHub Desktop.
Save vital101/3931327 to your computer and use it in GitHub Desktop.
def validate_urls(self, urls):
messages = []
for url in urls:
try:
request = urllib2.Request(url, headers={ "User-Agent" : "Sublime URL Checker" })
response = urllib2.urlopen(request, timeout=3)
message = '"%s" is a valid URL.' % url
except Exception as (e):
message = '"%s" is an invalid URL.' % url
messages.append(message)
return messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment