You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If i try to catch exeptions:
Code:
import requests
try:
response = requests.get('https://google.com',timeout=20)
if response.status_code == 200:
print (response.json())
else:
print(f"Fehler beim Abrufen der Daten. Statuscode: {response.status_code}")
except Exception as e:
print(f"Fehler: {str(e)}")
Output:
Fehler: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000215B98DE900>: Failed to establish a new connection: [WinError 10051] A socket operation was related to an unavailable network'))
Is it a firewall or some connection problems ? I´m clueless
The text was updated successfully, but these errors were encountered:
Hello,
i´m pretty new in Python programming.
I have python3 and i installed requests via pip.
I cant connect to any site with .get...
my code:
import requests
r = requests.get('http://google.com', timeout=20)
print(r.status_code)
Output: see file Output.txt
Output.txt
If i try to catch exeptions:
Code:
import requests
try:
response = requests.get('https://google.com',timeout=20)
if response.status_code == 200:
print (response.json())
else:
print(f"Fehler beim Abrufen der Daten. Statuscode: {response.status_code}")
except Exception as e:
print(f"Fehler: {str(e)}")
Output:
Fehler: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000215B98DE900>: Failed to establish a new connection: [WinError 10051] A socket operation was related to an unavailable network'))
Is it a firewall or some connection problems ? I´m clueless
The text was updated successfully, but these errors were encountered: