Errors with Python's mechanize module?

S' __init__. Py | grep Error 'BrowserStateError', 'ContentTooShortError', 'FormNotFoundError', 'GopherError', 'HTTPDefaultErrorHandler', 'HTTPError', 'HTTPErrorProcessor', 'LinkNotFoundError', 'LoadError', 'ParseError', 'RobotExclusionError', 'URLError', Or: >>> import mechanize >>> filter(lambda s: "Error" in s, dir(mechanize)) 'BrowserStateError', 'ContentTooShortError', 'FormNotFoundError', 'GopherError' , 'HTTPDefaultErrorHandler', 'HTTPError', 'HTTPErrorProcessor', 'LinkNotFoundErr or', 'LoadError', 'ParseError', 'RobotExclusionError', 'URLError'.

While this has been posted a long time ago, I think there is still a need to answer the question correctly since it comes up in Google's search results for this very question. As I write this, mechanize (version = (0, 1, 11, None, None)) in Python 265 raises urllib2. HTTPError and so the http status is available through catching this exception, eg: import urllib2 try: ... br.

Open("example.org/invalid-page") ... except urllib2. HTTPError, e: ... print e. Code ... 404.

I found this in their docs: One final thing to note is that there are some catch-all bare except: statements in the module, which are there to handle unexpected bad input without crashing your program. If this happens, it's a bug in mechanize, so please mail me the warning text. So I guess they don't raise any exceptions.

You can also search the source code for Exception subclasses and see how they are used.

1 I'm not sure you're right, because mechanize seems to propagate exceptions from underlying urllib2 calls – Eli Bendersky Sep 30 '08 at 6:12 In that case, urllib2 exceptions are very well documented: docs.python. Org/lib/module-urllib2. Html – Alexander Kojevnikov Sep 30 '08 at 6:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions