0

I'm trying to use this Yahoo Finance API with Python 2.7 and Requests.

Entering in this URL returns the data I need without an issue.

URL - http://chartapi.finance.yahoo.com/instrument/1.0/BHP.AX/chartdata;type=quote;range=1d/csv

Returns

timestamp,close,high,low,open,volume
1443571254,21.8800,21.8900,21.8400,21.8550,773600
1443571319,21.9000,21.9000,21.8400,21.8800,63900
1443571379,21.9200,21.9200,21.8700,21.8800,68800
1443571436,21.9350,21.9500,21.9000,21.9200,16700

But, when I try the same with Python eg.

import requests
r = requests.get('http://chartapi.finance.yahoo.com/instrument/1.0/BHP.ax/chartdata;type=quote;range=1d/csv')
print r

I get a ConnectionError.

I can't understand how the browser could return a result, when Requests times out.

JasTonAChair
  • 1,948
  • 1
  • 19
  • 31

1 Answers1

0

OK, the simple answer is I was using HTTP in python, but the API wanted HTTPS. Explained in another answer here.

Python requests.exception.ConnectionError: connection aborted "BadStatusLine"

JasTonAChair
  • 1,948
  • 1
  • 19
  • 31