问题
I have tried to use request:
url = 'http://bot' # this is a local service
import requests
r = requests.get(url)
and I get
requests.exceptions.SSLError: HTTPSConnectionPool(host='bot', port=443)
I specified HTTP, not HTTPS, but it tried to connect with SSL.
So, I tried httplib2:
url = 'http://bot' # this is a local service
response, content = http.request(url, "GET")
and I get:
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
I don't know why there is an obsession with HTTPS, but I don't want it. it's a local service running in development and it is pure HTTP. Adding ":80" to the url doesn't change anything.
When using CURL or C# to access the same service, through HTTP, no problem.
How can I tell python libs that I want a pure HTTP connection and nothing else?
回答1:
Use requests
library and add a ssl verify option. Your request line should look like this:
r = requests.get(url, verify = False)
回答2:
Try to disable SSL_VERIFICATION
r = requests.get(url, verify = False)
来源:https://stackoverflow.com/questions/57111689/in-python-i-want-to-do-rest-requests-with-http-and-not-with-https-packages-don