def forecast(self, timely='current'):
geolocator = GoogleV3()
location = geolocator.geocode(self.profile.get_location())
api_key = Config.open_api.dark_sky.TOKEN
lat = location.latitude
lon = location.longitude
dark_sky = forecastio.load_forecast(api_key, lat, lon)
if timely == 'current':
currently = dark_sky.currently()
self.__forecast(currently, timely, location.address)
elif timely == 'daily':
hourly = dark_sky.hourly()
self.__forecast(hourly, timely, location.address)
elif timely == 'weekly':
daily = dark_sky.daily()
self.__forecast(daily, timely, location.address)
评论列表
文章目录