Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from urllib2 import Request, urlopen, URLError
  2.  
  3. def is_valid_url(url):
  4.     req = Request(url, headers={'User-Agent' : "Magic Browser"})
  5.     try:
  6.         response = urlopen(req)
  7.     except URLError, e:
  8.         return False
  9.     else:
  10.         return True
  11.  
  12. errors = []
  13. word = 'linkedin.com'
  14. if is_valid_url(word):
  15.     print 'valid url'
  16.  
  17. else:
  18.     errors.append("- Something's fishy with that URL")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement