json - Curl in python program -
i'm using urllib in order output of multiple curls. outputs json , have array need correctly use curl:
for in array: url='http://example/' + +'/example2' urllib.urlretrieve(url,'data.json') open("data.json") file: data=json.load(file) inside loop, write csv file data retrieved json file save data.
the problem gives error whenever try call urllib.urlretrieve() second time, data.json file gets full of garbage characters. if call code once runs perfectly, if try run in loop or in sequence like:
url='http://example/' + array[0] +'/example2' urllib.urlretrieve(url,'data.json') open("data.json") file data=json.load(file) url='http://example/' + array[1] +'/example2' urllib.urlretrieve(url,'data.json') open("data.json") file: data=json.load(file) the file gets corrupted , isn't considered json json.load(). know problem here?
edit: error : valueerror: no json object decoded thats because second 'data.json' becomes corrupted , isn't considered json file.
the second output of data.json seems have html code of page.
thanks
Comments
Post a Comment