我正在尝试维护与代理的连接池。我的代码如下所示:
>>> from urllib3 import PoolManager
>>> pool = PoolManager(10)
>>> pool.urlopen('GET', 'http://http-server/index.html',fields=None,headers=None,encode_multipart=False,multipart_boundary=None,proxies={'http': 'http://proxy'})
当我运行它时,它失败了:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "urllib3/poolmanager.py", line 117, in urlopen
> response = conn.urlopen(method, u.request_uri, **kw)
> File "urllib3/connectionpool.py", line 427, in urlopen
> **response_kw)
> File "urllib3/response.py", line 195, in from_httplib
> **response_kw)
> TypeError: __init__() got an unexpected keyword argument 'proxies'
知道我做错了什么吗?根据 urllib3 文档,关键字 args 被发送到 urlopen,但在这种情况下似乎没有发生。
这是urllib的链接,描述了代理关键字 arg 的用法。