'HTTPConnectionPool'对象没有属性'get_url'

时间:2012-05-28 08:17:47

标签: python urllib3

这是我的代码:

import urllib3

url='http://www.google.com/'

http_pool = urllib3.connection_from_url(url)

content = http_pool.get_url('/')

print (content.info())
print ('----------------------------')
page = content.read()

print (page)

错误:

Traceback (most recent call last):
  File "C:\python\test.py", line 24, in <module>
    content = http_pool.get_url('/')
AttributeError: 'HTTPConnectionPool' object has no attribute 'get_url'

我贬低它,但没有任何相关性。 这太奇怪了,我无法弄清楚......

1 个答案:

答案 0 :(得分:2)

来自urllib3 docs

get_url(url, fields=None, **urlopen_kw)
Deprecated since version 1.0.

Use request() instead.