Created
October 22, 2012 12:42
-
-
Save vital101/3931327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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