diff --git a/HTTP/requests_client.py b/HTTP/requests_client.py new file mode 100644 index 0000000..83588ae --- /dev/null +++ b/HTTP/requests_client.py @@ -0,0 +1,4 @@ +import requests + +response = requests.get("http://vyatsu.ru") +print(response.text[:500]) \ No newline at end of file diff --git a/HTTP/socket_client.py b/HTTP/socket_client.py new file mode 100644 index 0000000..db4e0ae --- /dev/null +++ b/HTTP/socket_client.py @@ -0,0 +1,26 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client.connect(('vyatsu.ru', 80)) + +request = ( + "GET / HTTP/1.1\r\n" + "Host: vyatsu.ru\r\n" + "User-Agent: python-requests/2.33.1\r\n" + "Accept-Encoding: gzip, deflate, zstd\r\n" # ← Закомментировали + "Accept: */*\r\n" + "Connection: close\r\n" # ← лучше keep-alive заменить на close + "\r\n" +) + +client.sendall(request.encode()) + +full_response = b"" +while True: + chunk = client.recv(4096) + if not chunk: + break + full_response += chunk + +print(full_response.decode()) +client.close()