现象
1、request 请求 POST 接口的时候报错:
Traceback (most recent call last):
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 588, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 248, in _get_conn
return conn or self._new_conn()
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 826, in _new_conn
raise SSLError("Can't connect to HTTPS URL because the SSL "
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xxx.xxx.cn', port=443): Max retries exceeded with url: /order/supplyOrder/xxx (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/zhangc/Desktop/GitTest/2020Project/Python/2020_02_Selenium_Python/Request/Test/20210619/test.py", line 23, in <module>
r = requests.post(url,data)
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/Users/zhangc/.pyenv/versions/3.6.1/lib/python3.6/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='xxx.xxx.cn', port=443): Max retries exceeded with url: /order/supplyOrder/xxx (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",))
2、请求头类型:
3、代码如下:
import requests
# import ssl
data = {
"page": 1,
"rows": 50,
"status": 2,
"recyclerId": 3882055230,
"token": "eyJhbGciOiJIUzI1NiJ9.eyJyZWN5Y2xlck5hbWUiOlsi5ou-6LW35Y2W56eR5oqA5pyJ6ZmQ5YWs5Y-4Il0sInJvbGVJZCI6IjIxMCIsIm1hbnVmYWN0dXJlcklkIjpbIjEzODUwMjQ3NzEyIiwiMTM1NzAzOTQ5IiwiNzA2NDM2NDY4IiwiMjEzMjA1Mzg0IiwiNDkzNzA5MjgxIiwiNTY5NzEyMTk5IiwiNzU5NDY3NjkxIiwiMzU4NjA1MTk3IiwiMTEzODYyMjMxIiwiMTI3ODYyMDkzIiwiMTQ0MjkzNTIwIiwiMjIxNDIyOTI0IiwiMTIzNzUzMTMxIiwiMTMxNTE3MjIyIiwiMTM5MjYyMDg2IiwiMTQyNjk4ODI5IiwiMTQ5MDA5NDQzIiwiMTc1OTk4ODczIiwiMTg1MTgwNjk4IiwiMTk3ODM5NzQ3IiwiMjAxMzUzODEyMTEiLCI5Nzg0MDY1NTEiLCIxMDA5ODgzMDciLCIyOTQxNjkxOTQiLCIzODIwNzM0NjEiLCI4NTc3NTk5NDYiLCI5NDQ2OTM4MDA2IiwiMjg5MzU4NTk0IiwiNTUwODQyMTEyMCIsIjQzNDExNDQxOCIsIjEwMTAxMDEwMSIsIjA2OTI4MzQ5MDEiXSwidGVsZXBob25lIjoiMTc3Nzc3MDAwMjQiLCJzb3J0IjoxLCJ1c2VyTmFtZSI6Inh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