three commit
This commit is contained in:
parent
a854977fed
commit
08d33e1080
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.env
|
||||
.vscode/
|
||||
6
http_requests.py
Normal file
6
http_requests.py
Normal file
@ -0,0 +1,6 @@
|
||||
import requests
|
||||
|
||||
response = requests.get("http://vyatsu.ru")
|
||||
|
||||
print("Статус:", response.status_code)
|
||||
print(response.text[:500])
|
||||
25
http_socket.py
Normal file
25
http_socket.py
Normal file
@ -0,0 +1,25 @@
|
||||
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.31.0\r\n"
|
||||
"Accept: */*\r\n"
|
||||
"Connection: close\r\n\r\n"
|
||||
)
|
||||
|
||||
client.sendall(request.encode())
|
||||
|
||||
response = b""
|
||||
while True:
|
||||
chunk = client.recv(4096)
|
||||
if not chunk:
|
||||
break
|
||||
response += chunk
|
||||
|
||||
print(response.decode(errors="ignore"))
|
||||
|
||||
client.close()
|
||||
Loading…
Reference in New Issue
Block a user