如何获得https://stocks.exchange/api2/ticker

时间:2018-05-09 08:18:01

标签: json python-2.7 python-requests ticker

import json, requests

def tick():
    r = requests.get('https://stocks.exchange/api2/ticker')
    return r.json()
print tick()

此代码输出,

Traceback (most recent call last):
File "C:\Users\Steven\Desktop\Auto\tradeogre\stocksexchange.py", line 6, in 
<module>
print tick()
File "C:\Users\Steven\Desktop\Auto\tradeogre\stocksexchange.py", line 4, in 
tick
r = requests.get('https://stocks.exchange/api2/ticker')
File "C:\Python27\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 508, in 
request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 506, in send
raise SSLError(e, request=request)
SSLError: HTTPSConnectionPool(host='stocks.exchange', port=443): Max retries 
exceeded with url: /api2/ticker (Caused by SSLError(SSLEOFError(8, u'EOF 
occurred in violation of protocol (_ssl.c:661)'),))

如果不违反协议,我该怎么做?我使用了urllib,urllib2,并获得了similer响应。如果我在浏览器中输入url,它会显示我需要的数据。任何帮助将不胜感激。

0 个答案:

没有答案