【问题标题】:Not able to connect to https sites using urllib due to ssl error由于 ssl 错误,无法使用 urllib 连接到 https 站点
【发布时间】:2015-03-11 09:08:08
【问题描述】:
fh = urllib.urlopen('https://docs.python.org/2/library/urllib.html',proxies=proxies)

其中 proxies 是一个字典,如下所示:

proxies['http'] = "http//user_name:password@ip:port"
proxies['https'] = "https//user_name:password@ip:port"

注意:我在上面的 http 和 https 之后删除了冒号,因为它被视为一个链接,并且我不允许发布超过 2 个链接。

但我收到以下错误:

407      def _real_connect(self, addr, return_errno):
IOError: [Errno socket error] [Errno 1] _ssl.c:510: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

我尝试了“Python httplib SSL23_GET_SERVER_HELLO:unknown protocol”上给出的内容,但这给了我以下错误:

 407     def _real_connect(self, addr, return_errno):
 IOError: [Errno socket error] [Errno 8] _ssl.c:510: EOF occurred in violation of protocol

现在可能是因为大学代理,但我是通过代理提供的。

【问题讨论】:

    标签: python ssl proxy urllib


    【解决方案1】:

    您错过了 URI 中的 :

    proxies['http'] = "http://user_name:password@ip:port"
    proxies['https'] = "https://user_name:password@ip:port"
    

    【讨论】:

    • 实际上我已经给出了冒号,但是把它放在了这里的注释中,因为 stackexchange 将它视为一个我不想发生的 url,因为我只能发布 2 个链接。
    猜你喜欢
    • 1970-01-01
    • 2014-12-03
    • 1970-01-01
    • 2013-11-11
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    • 2013-03-29
    • 1970-01-01
    相关资源
    最近更新 更多