0

Actually,I am new to json-python, and i am getting error of simplejson.scanner.jsondecodeerror:expecting value Expecting value: line 1 column 1 (char 0), i am trying for ["series"]["TimeStamp"] data

import urllib 
import simplejson
response = urllib.urlopen("http://chartapi.finance.yahoo.com/instrument/1.0/RUSHIL.NS/chartdata;type=quote;range=5d/json")
#response.read()  //this works
data = simplejson.loads(response)
print data //error

1 Answer 1

1

I found that your data has some unnecessary words. Response has 'finance_charts_json_callback(' at the first of data. So you should remove this function string. The following code shows.

import urllib 
import simplejson
response = urllib.urlopen("http://chartapi.finance.yahoo.com/instrument/1.0/RUSHIL.NS/chartdata;type=quote;range=5d/json")
a = response.read()
a = a[29:-1] # remove function wrap
data = simplejson.loads(a)
print(data)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I didn't notice that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.