# http_requests_client.py import requests import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s') def http_get_requests(): """HTTP GET запрос через библиотеку requests""" try: url = "http://vyatsu.ru" # Выполняем GET запрос logging.info(f"Запрос к {url}") response = requests.get(url, timeout=10) # Информация об ответе logging.info(f"Статус код: {response.status_code} {response.reason}") logging.info(f"Время ответа: {response.elapsed.total_seconds():.3f} сек") logging.info(f"Размер ответа: {len(response.content)} байт") # Заголовки ответа logging.info("Основные заголовки:") for header in ['content-type', 'server', 'date']: if header in response.headers: logging.info(f" {header}: {response.headers[header]}") # Тело ответа (первые 500 символов) logging.info(f"Тело ответа:\n{response.text[:500]}") return response except requests.exceptions.RequestException as e: logging.error(f"Ошибка запроса: {e}") return None if __name__ == '__main__': http_get_requests()