• <small id='P3IJG'></small><noframes id='P3IJG'>

    <i id='P3IJG'><tr id='P3IJG'><dt id='P3IJG'><q id='P3IJG'><span id='P3IJG'><b id='P3IJG'><form id='P3IJG'><ins id='P3IJG'></ins><ul id='P3IJG'></ul><sub id='P3IJG'></sub></form><legend id='P3IJG'></legend><bdo id='P3IJG'><pre id='P3IJG'><center id='P3IJG'></center></pre></bdo></b><th id='P3IJG'></th></span></q></dt></tr></i><div id='P3IJG'><tfoot id='P3IJG'></tfoot><dl id='P3IJG'><fieldset id='P3IJG'></fieldset></dl></div>

      1. <legend id='P3IJG'><style id='P3IJG'><dir id='P3IJG'><q id='P3IJG'></q></dir></style></legend>

        • <bdo id='P3IJG'></bdo><ul id='P3IJG'></ul>

        <tfoot id='P3IJG'></tfoot>

        Python,带有基本身份验证的 HTTPS GET

        Python, HTTPS GET with basic authentication(Python,带有基本身份验证的 HTTPS GET)
          <i id='1mql2'><tr id='1mql2'><dt id='1mql2'><q id='1mql2'><span id='1mql2'><b id='1mql2'><form id='1mql2'><ins id='1mql2'></ins><ul id='1mql2'></ul><sub id='1mql2'></sub></form><legend id='1mql2'></legend><bdo id='1mql2'><pre id='1mql2'><center id='1mql2'></center></pre></bdo></b><th id='1mql2'></th></span></q></dt></tr></i><div id='1mql2'><tfoot id='1mql2'></tfoot><dl id='1mql2'><fieldset id='1mql2'></fieldset></dl></div>

        • <small id='1mql2'></small><noframes id='1mql2'>

            <bdo id='1mql2'></bdo><ul id='1mql2'></ul>

              <tbody id='1mql2'></tbody>

              • <tfoot id='1mql2'></tfoot>

                  <legend id='1mql2'><style id='1mql2'><dir id='1mql2'><q id='1mql2'></q></dir></style></legend>

                  本文介绍了Python,带有基本身份验证的 HTTPS GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Im trying to do a HTTPS GET with basic authentication using python. Im very new to python and the guides seem to use diffrent librarys to do things. (http.client, httplib and urllib). Can anyone show me how its done? How can you tell the standard library to use?

                  解决方案

                  In Python 3 the following will work. I am using the lower level http.client from the standard library. Also check out section 2 of rfc2617 for details of basic authorization. This code won't check the certificate is valid, but will set up a https connection. See the http.client docs on how to do that.

                  from http.client import HTTPSConnection
                  from base64 import b64encode
                  #This sets up the https connection
                  c = HTTPSConnection("www.google.com")
                  #we need to base 64 encode it 
                  #and then decode it to acsii as python 3 stores it as a byte string
                  userAndPass = b64encode(b"username:password").decode("ascii")
                  headers = { 'Authorization' : 'Basic %s' %  userAndPass }
                  #then connect
                  c.request('GET', '/', headers=headers)
                  #get the response back
                  res = c.getresponse()
                  # at this point you could check the status etc
                  # this gets the page text
                  data = res.read()  
                  

                  这篇关于Python,带有基本身份验证的 HTTPS GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Split a Pandas column of lists into multiple columns(将 Pandas 的列表列拆分为多列)
                  How does the @property decorator work in Python?(@property 装饰器在 Python 中是如何工作的?)
                  What is the difference between old style and new style classes in Python?(Python中的旧样式类和新样式类有什么区别?)
                  How to break out of multiple loops?(如何打破多个循环?)
                  How to put the legend out of the plot(如何将传说从情节中剔除)
                  Why is the output of my function printing out quot;Nonequot;?(为什么我的函数输出打印出“无?)
                    <legend id='EfSBR'><style id='EfSBR'><dir id='EfSBR'><q id='EfSBR'></q></dir></style></legend>

                      <bdo id='EfSBR'></bdo><ul id='EfSBR'></ul>

                        <small id='EfSBR'></small><noframes id='EfSBR'>

                          <tfoot id='EfSBR'></tfoot>

                          1. <i id='EfSBR'><tr id='EfSBR'><dt id='EfSBR'><q id='EfSBR'><span id='EfSBR'><b id='EfSBR'><form id='EfSBR'><ins id='EfSBR'></ins><ul id='EfSBR'></ul><sub id='EfSBR'></sub></form><legend id='EfSBR'></legend><bdo id='EfSBR'><pre id='EfSBR'><center id='EfSBR'></center></pre></bdo></b><th id='EfSBR'></th></span></q></dt></tr></i><div id='EfSBR'><tfoot id='EfSBR'></tfoot><dl id='EfSBR'><fieldset id='EfSBR'></fieldset></dl></div>
                              <tbody id='EfSBR'></tbody>