相关疑难解决方法(0)

Python请求SSL问题

自从我开始为此寻找解决方案以来,已经过了几天.

我一直在尝试使用请求通过代理发出https请求而没有运气.

尽管这已包含在我的一个更大的项目中,但它完成了这一切:

    import requests

    prox = 'xxx.xxx.xxx.xxx:xxx' # fill in valid proxy

    r = requests.get('https://ipdb.at', proxies={'http': prox,
                                                 'https': prox})
Run Code Online (Sandbox Code Playgroud)

我尝试了kward verify = False,但我不断得到相同的错误或其变体:

    Traceback (most recent call last):
      File "/Users/mg/Desktop/proxy_service.py", line 21, in <module>
        verify=False)
      File "/Library/Python/2.7/site-packages/requests/api.py", line 55, in get
        return request('get', url, **kwargs)
      File "/Library/Python/2.7/site-packages/requests/api.py", line 44, in request
        return session.request(method=method, url=url, **kwargs)
      File "/Library/Python/2.7/site-packages/requests/sessions.py", line 279, in request
        resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
      File "/Library/Python/2.7/site-packages/requests/sessions.py", line 374, in send
        r = adapter.send(request, **kwargs) …
Run Code Online (Sandbox Code Playgroud)

python ssl connect python-requests

8
推荐指数
1
解决办法
2万
查看次数

python请求库中的https代理支持

我正在使用python Requests库来做HTTP相关的事情.我在我的计算机上使用免费的ntlmaps设置了一个代理服务器,作为代理来回答公司ISA服务器的NTLM挑战.但是,响应似乎总是空的,如下所示:

>>> import requests
>>> r = requests.get('https://www.google.com')
>>> r.text
u'<HTML></HTML>\r\n'
Run Code Online (Sandbox Code Playgroud)

但http请求中没有这样的问题.而且,当我使用urllib2库时,它可以得到正确的响应.我比较了使用'Requests'和'urllib2'库之间的消息差异,发现'Requests'使用'GET'而'urllib2'使用'CONNECT',如下面所示的原始消息所示(第一个是'Requests'库).有人知道是否有任何解决方案?这是"请求"库的错误吗?提前致谢.

22.10.2012 11:01:41 Version 0.9.9.0.1
*** Got client request header.
*** Client header:
=====
GET https://www.google.com/ HTTP/1.1
Host: www.google.com
Proxy-Connection: Keep-Alive
Accept-Encoding: gzip, deflate, compress
Accept: */*
User-Agent: python-requests/0.14.1 CPython/2.7.2 Darwin/12.1.0

*** Client request header does not have 'Content-Length' or 'Transfer-Encoding' parameter and it must not have any body.
*** Replacing values in client header...Done.
*** New client header:
=====
GET https://www.google.com/ HTTP/1.1
Host: www.google.com
Proxy-Connection: Keep-Alive
Accept-Encoding: …
Run Code Online (Sandbox Code Playgroud)

python https proxy urllib2 python-requests

5
推荐指数
1
解决办法
6601
查看次数

标签 统计

python ×2

python-requests ×2

connect ×1

https ×1

proxy ×1

ssl ×1

urllib2 ×1