Skip to content

Instantly share code, notes, and snippets.

@dvdme
Last active April 23, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdme/34bb846055fc78f4bd2d937bcd7cda19 to your computer and use it in GitHub Desktop.
Save dvdme/34bb846055fc78f4bd2d937bcd7cda19 to your computer and use it in GitHub Desktop.
Get weather data from different cities from the past with forecastiopy
from forecastiopy import *
apikey = 'YOUR_APY_KEY'
Lisbon = [38.7252993, -9.1500364]
Madrid = [40.383333, -3.666667]
Paris = [48.866667, 2.332778]
def print_icon(lat, lon):
fio = ForecastIO.ForecastIO(apikey, latitude=lat, longitude=lon)
fio.time_url = '2006-12-01T12:00:00-0000'
fio.get_forecast(lat,lon) # Be sure to call get_forecast *after* you set the time_url
if fio.has_currently() is True:
currently = FIOCurrently.FIOCurrently(fio)
print currently.icon
print currently.temperature
print
else:
print 'No Currently data'
print_icon(Lisbon[0], Lisbon[1])
print_icon(Madrid[0], Madrid[1])
print_icon(Paris[0], Paris[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment