RosettaCodeData/Task/HTTP/Python/http-2.py

8 lines
335 B
Python
Raw Normal View History

2023-07-01 11:58:00 -04:00
from http.client import HTTPConnection
conn = HTTPConnection("example.com")
# If you need to use set_tunnel, do so here.
conn.request("GET", "/")
# Alternatively, you can use connect(), followed by the putrequest, putheader and endheaders functions.
result = conn.getresponse()
r1 = result.read() # This retrieves the entire contents.