Write a Python program to access and print a URL’s content to the console.
1 2 3 4 5 6 7 |
from http.client import HTTPConnection conn = HTTPConnection("example.com") conn.request("GET", "/") result = conn.getresponse() # retrieves the entire contents. contents = result.read() print(contents) |