404 errors

Derek Fountain devnull at example.com
Mon Apr 26 23:00:57 EDT 2004


I'm probably a bit off topic with this, but I'm not sure where else to ask.
Hopefully someone here will know the answer.

I'm writing a script (in Python) which reads a webpage from a user supplied
URL using urllib.urlopen. I want to detect an error from the server. If the
server doesn't exist, that's easy - catch the IOError. However, if the
server exists, but the path in the URL is wrong, how do I detect the error?
Some servers respond with a nicely formatted bit of HTML explaining the
problem, which is fine for a human, but not for a script. Is there some
flag or something definitive on the response which says "this is a 404
error"?



More information about the Python-list mailing list