-3

I use Python 3.4.2 on linux here's my code.

myurl = 'http://localhost/test.php'
response = urllib.urlopen(myurl) 

while response.text != 'exit':
    response = urllib.urlopen(myurl)  

And i got this error

  Traceback (most recent call last) :

     File "/var/www/html/led.py", line 19, in <module>

        response = urllib.urlopen(myurl)

  AttributeError: 'module' object has no attribute 'urlopen'
dlemstra
  • 7,813
  • 2
  • 27
  • 43
  • 1
    [`urllib.request.urlopen`](https://docs.python.org/3/library/urllib.request.html#module-urllib.request) in python 3 – M.T Jul 24 '16 at 13:25

1 Answers1

1

In python 3 the module is urllib.request.urlopen. Use it as shown below-

import urllib.request
# and then 
response = urllib.request.urlopen(myurl) 
sayan
  • 1,520
  • 17
  • 33