import json
import requests
from pprint import pprint
r = requests.get('http://www.geologycloud.tw/data/zh-tw/liquefaction?area=%E5%98%89%E7%BE%A9&classify=%E9%AB%98%E6%BD%9B%E5%8B%A2&all=true')
doc = json.loads(r.text)
pprint(doc['features'][0]['geometry']['coordinates'])
-
What's your question exactly ???bruno desthuilliers– bruno desthuilliers2017-03-21 15:06:13 +00:00Commented Mar 21, 2017 at 15:06
-
What is it that you're asking? The given code outputs something for me.PidgeyUsedGust– PidgeyUsedGust2017-03-21 15:07:48 +00:00Commented Mar 21, 2017 at 15:07
-
the code runs, I think they are just looking to save it to disk.tipanverella– tipanverella2017-03-21 15:10:33 +00:00Commented Mar 21, 2017 at 15:10
Add a comment
|
1 Answer
There are several ways to save data to disk. I would try this:
import json
import requests
from pprint import pprint
import pickle
r = requests.get('http://www.geologycloud.tw/data/zh-tw/liquefaction?area=%E5%98%89%E7%BE%A9&classify=%E9%AB%98%E6%BD%9B%E5%8B%A2&all=true')
doc = json.loads(r.text)
pprint(doc['features'][0]['geometry']['coordinates'])
with open('data.pkl', 'wb') as output:
pickle.dump(doc['features'][0]['geometry']['coordinates'], output)