python API请求——SSL报错
During handling of the above exception, another exception occurred: Traceback (most recent call last): File ".\getOpsMindMetrics.py", line 50, in <module> getOpsMindData.getOpsMind_CPUdata('GS-JW-ZW-YOUKU-SDK-GSXMT-QZJ-01') File ".\getOpsMindMetrics.py", line 42, in getOpsMind_CPUdata req = requests.get(URL) File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 76, in get return request('get', url, params=params, **kwargs) File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 542, in request resp = self.send(prep, **send_kwargs) File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='local.private.opsmind.com', port=443): Max retries exceeded with url: /v1/prom/api/v1/query_range/query=sum%28avg%28irate%28dog_cpu_time%5C%7B%5C%7Bhost%3D-%22GS-JW-ZW-YOUKU-SDK-GSXMT-QZJ-01%22%2C__tunning__%3D%22try_stop_search_index%22%2Ccpu%3D~%22.%2A%22%2Cmode%3D-%22user%2Csys%2Cirq%2Ciowait%22%5C%7D%5C%7D%5B6m%5D%29%29+WITHOUT+%28cpu%29%29+WITHOUT+%28mode%29&start=1637745900&end=1637745925&step=1m (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))
关闭验证:verify=False
req = requests.get(URL, verify=False)
验证结果:无SSL报错
C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py:988: InsecureRequestWarning: Unverified HTTPS request is being made to host 'local.private.opsmind.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning, Status code: 404 <Response [404]>