Python Forum

Full Version: HTTP response capturing issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to catch a specific HTTP error and not any one of the entire family.. what I was trying to do is
import urllib2
try:
   urllib2.urlopen("some url")
except urllib2.HTTPError:
   <whatever>
but what I end up is catching any kind of HTTP error, but I want to catch only if the specified webpage doesn't exist!! probably that's HTTP error 404..but I don't know how to specify that catch only error 404 and let the system run the default handler for other events.
that should only capture the urllib2.HTTPError.
what makes you think it doesn't?
If it's because you still see the other errors, that's because they were not captured but rather sent to stderr which is usual.