3

I read somewhere that currently urllib2 doesn't support authenticated https connection. My proxy uses a basic authentication only, but how to open an https based webpage through it . Please help me.

Thanks.

user55435
  • 31
  • 1
  • Duplicate: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection, http://stackoverflow.com/questions/426298/how-to-use-the-httppasswordmgrwithdefaultrealm-in-python – S.Lott Jan 15 '09 at 15:16

2 Answers2

2

"urllib2 doesn't support authenticated https connection" False.

    # Build Handler to support HTTP Basic Authentication...
    basic_handler = urllib2.HTTPBasicAuthHandler()
    basic_handler.add_password(realm, self.urlBase, username, password)
    # Get cookies, also, to handle login
    self.cookies= cookielib.CookieJar()
    cookie_handler= urllib2.HTTPCookieProcessor( self.cookies )
    # Assemble the final opener
    opener = urllib2.build_opener(basic_handler,cookie_handler)
S.Lott
  • 384,516
  • 81
  • 508
  • 779
0

You can use httplib2, which solves some of the limitations of urllib2 including this one. There is an example here of how to do Basic Authentication on a https connection.

dF.
  • 74,139
  • 30
  • 130
  • 136