我使用此代码在 IP 地址中获取组织
import urllib
import lxml.html as lh
req= urllib.Request("http://www.ip-address.com/ip_tracer/157.123.22.11", headers={'User-Agent' : "Magic Browser"})
html = urllib.urlopen(req).read()
doc = lh.fromstring(html)
print (''.join(doc.xpath('.//*[@class="odd"]')[-1].text_content().split()))
我的 python 是 3.2.3,它显示
Traceback (most recent call last):
File "ext.py", line 3, in <module>
req= urllib.Request("http:// www.ip-address.com/ip_tracer/157.123.22.11", headers={'User-Agent' : "Magic Browser"})
AttributeError: 'module' object has no attribute 'Request'
如何解决它。谢谢,