For a url entered by the user :
check that is any webserver hosting the domain name or not ?
For example :
url='laksjdfaksdfjajdfaljewoifjadslkjflkasjrlwkejk.com'
Now, the above url does-not exists, so there is no point of check for any HTTP error codes since, no server is there that will reply back.
So, how to detect such url ?
isServerUp() ?
This should open the url for you; obviously change how you want to say that the url has failed to open. The docs are: http://docs.python.org/library/urllib2.html
EDIT: Indentation fixed