HTTP Authentication using urllib2

Wojtek Walczak gminick at bzt.bzt
Fri Apr 24 17:45:10 EDT 2009


On Fri, 24 Apr 2009 04:25:20 -0700 (PDT), Lakshman wrote:
> I am trying to authenticate using urllib2. The basic authentication
> works if I hard code authheaders.
...
>     except IOError, e:
>         print "Something wrong. This shouldnt happen"

First of all, don't shoot yourself in the foot and check what
the exceptions are, i.e.:

      except:
         import traceback
         print traceback.format_exc()

Second, better use mechanize:

http://wwwsearch.sourceforge.net/mechanize/

HTH,
-- 
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/



More information about the Python-list mailing list