I am trying to see a redirect for pricipal.com. When using the developer tools I can see that the redirect fails with status code 400. However, when using python I see Status Code: 200
This is the code I'm using:
import requests
import urllib.request, urllib.error
import vertica_python
r = requests.get('http://pricipal.com')
t = requests.ReadTimeout()
try:
print('#################')
# d = geturl(r)
# print(r.status_code)
print("{}: {}".format(r, r.status_code))
print('URL: ' + r.url)
print("{}: {}".format('History: ', r.history))
print("{}: {}".format(r, r.status_code))
print('#################')
except requests.ConnectionError:
# prints the int of the status code. Find more at httpstatusrappers.com :)
print('######FAIL#######')
print(r + ": failed to connect")
print(r.ConnectionError)
print(r.url)
print('Read timeout: ' + t)
print('#################')
print('done')
How can I modify the code to properly display that the redirect has status code 400 and not 200?
Thank you!