Skip to content

Instantly share code, notes, and snippets.

@gladson
Created December 1, 2011 03:06
Show Gist options
  • Select an option

  • Save gladson/1413141 to your computer and use it in GitHub Desktop.

Select an option

Save gladson/1413141 to your computer and use it in GitHub Desktop.
clima gladson
from django.template import RequestContext
from django.shortcuts import render_to_response,
from xml.dom import minidom
import urllib2
def rondonia_cafe_capa(request):
GOOGLE_WEATHER_URL = 'http://www.google.com/ig/api?weather=porto+velho&hl=pt-BR&ie=UTF-16&ll=-8.760224,-63.901978&spn=3.794279,6.696167&sll=-9.020728,-63.726196&sspn=3.791585,6.696167&vpsrc=0&hnear=Porto+Velho+-+Rond%C3%B4nia&t=h&z=8'
url = GOOGLE_WEATHER_URL
weather = {}
dom = minidom.parse(urllib2.urlopen(url))
weather['city'] = get_data(dom, "city")
forecasts = []
for node in dom.getElementsByTagName("forecast_conditions"):
forecast = {
'day_of_week': get_data(node, "day_of_week"),
'condition': get_data(node, "condition"),
}
forecasts.append(forecast)
weather['forecasts'] = forecasts
return render_to_response(
'teste/capa.html',
{
'weather': weather,
},
context_instance=RequestContext(request)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment