Python 3.2.3 running error
Question: I using this code to get the organization in ip address

    
    
    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()))
    

My python is 3.2.3, it shows

    
    
      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'
    

how to solve it. Thanks,


Answer: If you want to use
[`urllib.request.Request`](http://docs.python.org/py3k/library/urllib.request.html#urllib.request.Request),
import it like this:

    
    
    import urllib.request
    
    r = urllib.request.Request(...)
    html = urllib.request.urlopen(r).read()
    

If you need nothing else from `urllib.request`, you can import only `Request`:

    
    
    from urllib.request import Request
    
    r = Request(...)
    

