I was able to do the equivalent of this using the open weather api (need to create an account and get a key).
location is a string eg. “London,uk”
key is obtained from openweathermap.org
url = “https://api.openweathermap.org/data/2.5/forecast?q={}&units=metric&appid={}”.format(location, api_key)
resp = anvil.http.request(url, json=True)
forecast_list = resp[‘list’]
temp = [x[‘main’][‘temp’] for x in forecast_list]
date_dtime = [x[‘dt_txt’] for x in forecast_list]
return { ‘date_time’ : date_dtime, ‘temp’: temp }