programming-examples/python/_Basics/Access and print a URL's content to the console.py

7 lines
227 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
from http.client import HTTPConnection
conn = HTTPConnection("example.com")
conn.request("GET", "/")
result = conn.getresponse()
# retrieves the entire contents.
contents = result.read()
print(contents)