Код: Выделить всё
import requests
r = requests.get("http://non-existent-domain.test")
Код: Выделить всё
ConnectionError: HTTPConnectionPool(host='non-existent-domain.test', port=80): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
Код: Выделить всё
try:
r = requests.get("http://non-existent-domain.test")
except ConnectionError:
print("ConnectionError")
Подробнее здесь: https://stackoverflow.com/questions/409 ... h-requests
Мобильная версия