What is the error?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
8th May 2020, 6:03 PM
Jayant Agarwal
Jayant Agarwal - avatar
4 Answers
+ 1
use import urllib.request instead of import urllib
8th May 2020, 6:10 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Is your program running
8th May 2020, 6:11 PM
Jayant Agarwal
Jayant Agarwal - avatar
+ 1
Ok
8th May 2020, 6:12 PM
Jayant Agarwal
Jayant Agarwal - avatar
+ 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.
8th May 2020, 6:16 PM
akamhy
akamhy - avatar