+ 1
What is the error??
6 Respostas
+ 1
use
import urllib.request
instead of
import urllib
+ 1
Is your program running
+ 1
Ok
+ 1
from urllib.request import urlopen
import webbrowser
resp = urlopen('http://www.ted.com/')
html = resp.read( )
data = resp.getcode( )
url = resp.geturl( )
hd = resp.headers
inf = resp.info( )
print("the url is",url)
print("HTTP status code is :",data)
print("headers returned \n",hd)
print("the info( ) returned :\n",inf)
print("now opening the url",url)
webbrowser.open_new(url)
please use from urllib.request import urlopen. It's much cleaner.