urllib2 - safe way to download something

konstantin konstantin.selivanov at gmail.com
Fri Nov 14 12:06:27 EST 2008


On 14 нояб, 18:12, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Fri, 14 Nov 2008 06:35:27 -0800, konstantin wrote:
> > Hi,
>
> > I wonder if there is a safe way to download page with urllib2. I've
> > constructed following method to catch all possible exceptions.
>
> See here:
>
> http://niallohiggins.com/2008/04/05/python-and-poor-documentation-
> urllib2urlopen-exception-layering-problems/
>
> There are probably others as well... I seem to recall getting
> socket.error at some point myself.
>
> --
> Steven

Thanks. It's a nice post. But it seems there is no clear solution.
I remember I've caught IOError and ValueError as well.
I think urllib2 needs some unification on exception handling. It
breaks simplicity and this is no good.

But anyway, thanks.

ps Maybe I could contribute to this module but I do not really know
how and where to start.




More information about the Python-list mailing list