I wrote a python script with requests to send requests a list of domains, I use
try
requests.get('http://example.com')
except requests.exceptions.RequestException as e:
pass
to handle exceptions such as timeout, or too many redirections, as described in Correct way to try/except using Python requests module?.
However, there is an issues that some sites support only http scheme, while others support only https. In other words, if I send request to http://example.com, it does not redirect to https://example.com. Because of this, requests gives "failed to establish a new connection" error, complain that http://example.cm does not exist and terminates the program.
I wonder if there is a way to let me bypass such error, and continue to send request to the next host.