tsest_rep/http_requests.py

30 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
def http_via_requests():
try:
print("🔄 Отправляем HTTP-запрос к vyatsu.ru...")
response = requests.get("http://vyatsu.ru", timeout=10)
print("✅ Ответ получен!")
print("\n" + "="*50)
print("ИНФОРМАЦИЯ О ЗАПРОСЕ:")
print("="*50)
print(f"📊 Статус код: {response.status_code}")
print(f"🔗 URL: {response.url}")
print(f"📏 Размер ответа: {len(response.text)} символов")
print(f"\n📋 ЗАГОЛОВКИ ОТВЕТА:")
for header, value in response.headers.items():
print(f" {header}: {value}")
print(f"\n📄 СОДЕРЖИМОЕ (первые 500 символов):")
print(response.text[:500])
if len(response.text) > 500:
print("... (содержимое обрезано)")
except requests.RequestException as e:
print(f"❌ Ошибка запроса: {e}")
if __name__ == "__main__":
http_via_requests()