from urllib import request import json
def fetch_data(url): with request.urlopen(url) as f: print('status:', f.status, f.reason) data = f.read() obj = json.loads(data.decode('utf-8')) return obj
URL = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20%3D%202151330&format=json' data = fetch_data(URL) print(data)
Sign in to make a reply
xinyujaychou
from urllib import request import json
def fetch_data(url): with request.urlopen(url) as f: print('status:', f.status, f.reason) data = f.read() obj = json.loads(data.decode('utf-8')) return obj
URL = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20%3D%202151330&format=json' data = fetch_data(URL) print(data)