Попытка сделать REST получить с использованием Jython, но получить SSLError
.
Python 2.7.1 (default:0df7adb1b397, Jun 30 2017, 19:02:43)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_172
>>> import requests
>>> r = requests.get('https://jsonplaceholder.typicode.com/posts/1')
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\jython2.7.1\Lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\jython2.7.1\Lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\jython2.7.1\Lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\jython2.7.1\Lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\jython2.7.1\Lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
SSLError: HTTPSConnectionPool(host='jsonplaceholder.typicode.com', port=443): Max retries exceeded with url: /posts/1 (Caused by SSLError(SSLError(1, u'Received fatal alert: handshake_failure'),))
Обычный java способ сделать это работает.
>>> import java.net.URL as URL
>>> url = URL("https://jsonplaceholder.typicode.com/posts/1")
>>> conn = url.openConnection()
>>> conn.setRequestMethod("GET")
>>> conn.setRequestProperty("Accept", "application/json")
>>> conn.getResponseCode()
200
Почему я получить SSLError
при использовании requests
? Нужна ли какая-то дополнительная настройка, чтобы она работала?