# Program to print contents of a URL # It just prints the raw web page (no charset conversion) # Matt Bishop, ECS 10, Spring 2014 # import urllib.request # # ask for the URL # try: urlname = input("Please enter the URL: ") except EOFError: print("Bye!") except: print("That's not a valid string. ") else: # # got it -- now try to read from the URL # try: webpage = urllib.request.urlopen(urlname) except: print("URL retrieval failed!") else: # Read from the object, storing the page's contents in 's'. # and print it s = str(webpage.readall()) print(s)