29 lines
520 B
Python
29 lines
520 B
Python
import socket
|
|
|
|
HOST = "vyatsu.ru"
|
|
PORT = 80
|
|
|
|
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
client.connect((HOST, PORT))
|
|
|
|
request = (
|
|
"GET / HTTP/1.1\r\n"
|
|
"Host: vyatsu.ru\r\n"
|
|
"Connection: close\r\n"
|
|
"User-Agent: PythonSocketClient/1.0\r\n"
|
|
"Accept: */*\r\n"
|
|
"\r\n"
|
|
)
|
|
|
|
client.sendall(request.encode("utf-8"))
|
|
|
|
response = b""
|
|
while True:
|
|
part = client.recv(4096)
|
|
if not part:
|
|
break
|
|
response += part
|
|
|
|
client.close()
|
|
|
|
print(response.decode("utf-8", errors="ignore")) |