2
import json, requests

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

This code outputs,

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)'),))

How would I do this without violating the protocol? I have used urllib, urllib2, and get similer responses. If I enter the url in the browser, it displays the data I need. Any help would be greatly appreciated.

RoachNut
  • 21
  • 1
  • works for me. Maybe you have to go via a web proxy ? use `requests.get('https://stocks.exchange/api2/ticker', proxies={'https': 'yourproxyhost:yourproxyport'})`. It would explain why your browser works (if it is already configured to use the proxy). – Guillaume May 09 '18 at 09:22
  • Thank you! It actually worked after I rebooted my computer. Wow, what a simple fix. This was driving me nuts. – RoachNut May 09 '18 at 11:33
  • Did you have fiddler opened? Sometimes it does strange things with the network connections and only a reboot fixes it. – Guillaume May 09 '18 at 11:38

0 Answers0